Make *SURE* to null out the pointer before throwing an exception, otherwise
authorChris Lattner <sabre@nondot.org>
Mon, 15 Nov 2004 21:55:33 +0000 (21:55 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 15 Nov 2004 21:55:33 +0000 (21:55 +0000)
the dtor for the BytecodeReader class will try to free it again!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17856 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Bytecode/Reader/Reader.cpp

index 65d4c1c15d7d89d60e0680b2416733bb3203e5aa..6743bc8da0bbdb89f60ff2dbbabf2a16556eea5d 100644 (file)
@@ -2240,8 +2240,10 @@ void BytecodeReader::ParseBytecode(BufPtr Buf, unsigned Length,
     freeState();
     delete TheModule;
     TheModule = 0;
-    if (decompressedBlock != 0 )
+    if (decompressedBlock != 0 ) {
       ::free(decompressedBlock);
+      decompressedBlock = 0;
+    }
     throw;
   } catch (...) {
     std::string msg("Unknown Exception Occurred");
@@ -2249,8 +2251,10 @@ void BytecodeReader::ParseBytecode(BufPtr Buf, unsigned Length,
     freeState();
     delete TheModule;
     TheModule = 0;
-    if (decompressedBlock != 0 )
+    if (decompressedBlock != 0) {
       ::free(decompressedBlock);
+      decompressedBlock = 0;
+    }
     throw msg;
   }
 }