summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bitcode/Reader/BitReader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitReader.cpp')
-rw-r--r--llvm/lib/Bitcode/Reader/BitReader.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitReader.cpp b/llvm/lib/Bitcode/Reader/BitReader.cpp
index e21d29ac374..76a7e6ae159 100644
--- a/llvm/lib/Bitcode/Reader/BitReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitReader.cpp
@@ -51,8 +51,11 @@ LLVMBool LLVMGetBitcodeModuleInContext(LLVMContextRef ContextRef,
LLVMModuleRef *OutM,
char **OutMessage) {
std::string Message;
+ std::unique_ptr<MemoryBuffer> Owner(unwrap(MemBuf));
+
ErrorOr<Module *> ModuleOrErr =
- getLazyBitcodeModule(unwrap(MemBuf), *unwrap(ContextRef));
+ getLazyBitcodeModule(Owner, *unwrap(ContextRef));
+ Owner.release();
if (std::error_code EC = ModuleOrErr.getError()) {
*OutM = wrap((Module *)nullptr);
OpenPOWER on IntegriCloud