mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 04:30:23 +00:00
Do not leak the ModuleProvider if releaseModule() throws.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8847 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ded46e27cc
commit
a983359f59
@ -166,17 +166,14 @@ getBytecodeBufferModuleProvider(const unsigned char *Buffer, unsigned Length,
|
||||
///
|
||||
Module *ParseBytecodeBuffer(const unsigned char *Buffer, unsigned Length,
|
||||
const std::string &ModuleID, std::string *ErrorStr){
|
||||
Module *M = 0;
|
||||
try {
|
||||
AbstractModuleProvider *AMP =
|
||||
getBytecodeBufferModuleProvider(Buffer, Length, ModuleID);
|
||||
M = AMP->releaseModule();
|
||||
delete AMP;
|
||||
std::auto_ptr<AbstractModuleProvider>
|
||||
AMP(getBytecodeBufferModuleProvider(Buffer, Length, ModuleID));
|
||||
return AMP->releaseModule();
|
||||
} catch (std::string &err) {
|
||||
if (ErrorStr) *ErrorStr = err;
|
||||
return 0;
|
||||
}
|
||||
return M;
|
||||
}
|
||||
|
||||
/// getBytecodeModuleProvider - lazy function-at-a-time loading from a file
|
||||
@ -192,14 +189,12 @@ getBytecodeModuleProvider(const std::string &Filename) {
|
||||
/// ParseBytecodeFile - Parse the given bytecode file
|
||||
///
|
||||
Module *ParseBytecodeFile(const std::string &Filename, std::string *ErrorStr) {
|
||||
Module *M = 0;
|
||||
try {
|
||||
AbstractModuleProvider *AMP = getBytecodeModuleProvider(Filename);
|
||||
M = AMP->releaseModule();
|
||||
delete AMP;
|
||||
std::auto_ptr<AbstractModuleProvider>
|
||||
AMP(getBytecodeModuleProvider(Filename));
|
||||
return AMP->releaseModule();
|
||||
} catch (std::string &err) {
|
||||
if (ErrorStr) *ErrorStr = err;
|
||||
return 0;
|
||||
}
|
||||
return M;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user