Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit b279154

Browse files
committed
Revert a C API difference that I incorrectly introduced.
LLVMGetBitcodeModuleInContext should not take ownership on error. I will try to localize this odd api requirement, but this should get the bots green. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211213 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent fff95d5 commit b279154

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

lib/Bitcode/Reader/BitcodeReader.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3380,6 +3380,7 @@ ErrorOr<Module *> llvm::getLazyBitcodeModule(MemoryBuffer *Buffer,
33803380
BitcodeReader *R = new BitcodeReader(Buffer, Context, BufferOwned);
33813381
M->setMaterializer(R);
33823382
if (std::error_code EC = R->ParseBitcodeInto(M)) {
3383+
R->releaseBuffer(); // Never take ownership on error.
33833384
delete M; // Also deletes R.
33843385
return EC;
33853386
}

lib/Bitcode/Reader/BitcodeReader.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,10 @@ class BitcodeReader : public GVMaterializer {
239239

240240
void FreeState();
241241

242+
void releaseBuffer() {
243+
Buffer = nullptr;
244+
}
245+
242246
bool isMaterializable(const GlobalValue *GV) const override;
243247
bool isDematerializable(const GlobalValue *GV) const override;
244248
std::error_code Materialize(GlobalValue *GV) override;

0 commit comments

Comments
 (0)