Fix minor memory leak
authorChris Lattner <sabre@nondot.org>
Fri, 8 Mar 2002 18:57:56 +0000 (18:57 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 8 Mar 2002 18:57:56 +0000 (18:57 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1837 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AsmParser/llvmAsmParser.y

index fb024ed87948c93245981e67a2d03fa6952b50e9..9d6c99d41ee3542909fd8ffcd4a237330492ce50 100644 (file)
@@ -1210,6 +1210,12 @@ MethodHeaderH : OptInternal TypesV STRINGCONSTANT '(' ArgList ')' {
       ArgList.push_back(I->first);
     }
     delete $5;                     // We're now done with the argument list
+  } else if ($5) {
+    // If we are a declaration, we should free the memory for the argument list!
+    for (list<pair<MethodArgument*, char*> >::iterator I = $5->begin();
+         I != $5->end(); ++I)
+      if (I->second) free(I->second);   // Free the memory for the name...
+    delete $5;                          // Free the memory for the list itself
   }
 }