From 3bdad6923eae8ce356ce9392e96707064fdf1bc3 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 15 Nov 2004 21:55:33 +0000 Subject: [PATCH] Make *SURE* to null out the pointer before throwing an exception, otherwise 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 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/Bytecode/Reader/Reader.cpp b/lib/Bytecode/Reader/Reader.cpp index 65d4c1c15d7..6743bc8da0b 100644 --- a/lib/Bytecode/Reader/Reader.cpp +++ b/lib/Bytecode/Reader/Reader.cpp @@ -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; } }