mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-06 06:33:24 +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,
|
Module *ParseBytecodeBuffer(const unsigned char *Buffer, unsigned Length,
|
||||||
const std::string &ModuleID, std::string *ErrorStr){
|
const std::string &ModuleID, std::string *ErrorStr){
|
||||||
Module *M = 0;
|
|
||||||
try {
|
try {
|
||||||
AbstractModuleProvider *AMP =
|
std::auto_ptr<AbstractModuleProvider>
|
||||||
getBytecodeBufferModuleProvider(Buffer, Length, ModuleID);
|
AMP(getBytecodeBufferModuleProvider(Buffer, Length, ModuleID));
|
||||||
M = AMP->releaseModule();
|
return AMP->releaseModule();
|
||||||
delete AMP;
|
|
||||||
} catch (std::string &err) {
|
} catch (std::string &err) {
|
||||||
if (ErrorStr) *ErrorStr = err;
|
if (ErrorStr) *ErrorStr = err;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return M;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// getBytecodeModuleProvider - lazy function-at-a-time loading from a file
|
/// 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
|
/// ParseBytecodeFile - Parse the given bytecode file
|
||||||
///
|
///
|
||||||
Module *ParseBytecodeFile(const std::string &Filename, std::string *ErrorStr) {
|
Module *ParseBytecodeFile(const std::string &Filename, std::string *ErrorStr) {
|
||||||
Module *M = 0;
|
|
||||||
try {
|
try {
|
||||||
AbstractModuleProvider *AMP = getBytecodeModuleProvider(Filename);
|
std::auto_ptr<AbstractModuleProvider>
|
||||||
M = AMP->releaseModule();
|
AMP(getBytecodeModuleProvider(Filename));
|
||||||
delete AMP;
|
return AMP->releaseModule();
|
||||||
} catch (std::string &err) {
|
} catch (std::string &err) {
|
||||||
if (ErrorStr) *ErrorStr = err;
|
if (ErrorStr) *ErrorStr = err;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return M;
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user