Skip to content

Commit bc062e0

Browse files
committed
[ORC] Fix a memory leak in LLVMOrcIRTransformLayerSetTransform.
This function heap-allocates a ThreadSafeModule (the current C bindings assume that TSMs are always heap-allocated), but was failing to free it. Should fix http://llvm.org/PR56953.
1 parent 4246269 commit bc062e0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

llvm/lib/ExecutionEngine/Orc/OrcV2CBindings.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,10 @@ void LLVMOrcIRTransformLayerSetTransform(
892892
assert(!TSMRef && "TSMRef was not reset to null on error");
893893
return unwrap(Err);
894894
}
895-
return std::move(*unwrap(TSMRef));
895+
assert(TSMRef && "Transform succeeded, but TSMRef was set to null");
896+
ThreadSafeModule Result = std::move(*unwrap(TSMRef));
897+
LLVMOrcDisposeThreadSafeModule(TSMRef);
898+
return std::move(Result);
896899
});
897900
}
898901

0 commit comments

Comments
 (0)