mirror of
https://github.com/RPCSX/llvm.git
synced 2024-12-04 10:04:33 +00:00
Destroy allocated resources on exception.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8969 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
608e75c604
commit
7f58de2b99
@ -59,8 +59,13 @@ BytecodeFileReader::BytecodeFileReader(const std::string &Filename) {
|
||||
if (Buffer == (unsigned char*)MAP_FAILED)
|
||||
throw std::string("Error mmapping file!");
|
||||
|
||||
// Parse the bytecode we mmapped in
|
||||
ParseBytecode(Buffer, Length, Filename);
|
||||
try {
|
||||
// Parse the bytecode we mmapped in
|
||||
ParseBytecode(Buffer, Length, Filename);
|
||||
} catch (...) {
|
||||
munmap((char*)Buffer, Length);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
BytecodeFileReader::~BytecodeFileReader() {
|
||||
@ -106,7 +111,12 @@ BytecodeBufferReader::BytecodeBufferReader(const unsigned char *Buf,
|
||||
ParseBegin = Buffer = Buf;
|
||||
MustDelete = false;
|
||||
}
|
||||
ParseBytecode(ParseBegin, Length, ModuleID);
|
||||
try {
|
||||
ParseBytecode(ParseBegin, Length, ModuleID);
|
||||
} catch (...) {
|
||||
if (MustDelete) delete [] Buffer;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
BytecodeBufferReader::~BytecodeBufferReader() {
|
||||
|
Loading…
Reference in New Issue
Block a user