[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.
This commit is contained in:
Lang Hames 2022-08-05 12:03:34 -07:00
parent 424626953e
commit bc062e034f

View File

@ -892,7 +892,10 @@ void LLVMOrcIRTransformLayerSetTransform(
assert(!TSMRef && "TSMRef was not reset to null on error");
return unwrap(Err);
}
return std::move(*unwrap(TSMRef));
assert(TSMRef && "Transform succeeded, but TSMRef was set to null");
ThreadSafeModule Result = std::move(*unwrap(TSMRef));
LLVMOrcDisposeThreadSafeModule(TSMRef);
return std::move(Result);
});
}