Fix use-after-free error.
authorOwen Anderson <resistor@mac.com>
Fri, 23 Jul 2010 23:27:43 +0000 (23:27 +0000)
committerOwen Anderson <resistor@mac.com>
Fri, 23 Jul 2010 23:27:43 +0000 (23:27 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@109288 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/IRReader.h

index fe47c05..3da6e85 100644 (file)
@@ -79,10 +79,10 @@ namespace llvm {
                   (const unsigned char *)Buffer->getBufferEnd())) {
       std::string ErrMsg;
       Module *M = ParseBitcodeFile(Buffer, Context, &ErrMsg);
                   (const unsigned char *)Buffer->getBufferEnd())) {
       std::string ErrMsg;
       Module *M = ParseBitcodeFile(Buffer, Context, &ErrMsg);
-      // ParseBitcodeFile does not take ownership of the Buffer.
-      delete Buffer;
       if (M == 0)
         Err = SMDiagnostic(Buffer->getBufferIdentifier(), ErrMsg);
       if (M == 0)
         Err = SMDiagnostic(Buffer->getBufferIdentifier(), ErrMsg);
+      // ParseBitcodeFile does not take ownership of the Buffer.
+      delete Buffer;
       return M;
     }
 
       return M;
     }