[llvm-commits] CVS: llvm/lib/Bytecode/Reader/ReaderWrappers.cpp
Misha Brukman
brukman at cs.uiuc.edu
Wed Oct 8 14:56:01 PDT 2003
Changes in directory llvm/lib/Bytecode/Reader:
ReaderWrappers.cpp updated: 1.12 -> 1.13
---
Log message:
Destroy allocated resources on exception.
---
Diffs of the changes: (+13 -3)
Index: llvm/lib/Bytecode/Reader/ReaderWrappers.cpp
diff -u llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.12 llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.13
--- llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.12 Sun Oct 5 22:30:28 2003
+++ llvm/lib/Bytecode/Reader/ReaderWrappers.cpp Wed Oct 8 14:55:47 2003
@@ -59,8 +59,13 @@
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 @@
ParseBegin = Buffer = Buf;
MustDelete = false;
}
- ParseBytecode(ParseBegin, Length, ModuleID);
+ try {
+ ParseBytecode(ParseBegin, Length, ModuleID);
+ } catch (...) {
+ if (MustDelete) delete [] Buffer;
+ throw;
+ }
}
BytecodeBufferReader::~BytecodeBufferReader() {
More information about the llvm-commits
mailing list