[llvm-commits] [llvm] r119842 - /llvm/trunk/lib/Support/CommandLine.cpp

Rafael Espindola rafael.espindola at gmail.com
Fri Nov 19 13:14:29 PST 2010


Author: rafael
Date: Fri Nov 19 15:14:29 2010
New Revision: 119842

URL: http://llvm.org/viewvc/llvm-project?rev=119842&view=rev
Log:
Fix a use after free. Patch by Frits van Bommel.

Modified:
    llvm/trunk/lib/Support/CommandLine.cpp

Modified: llvm/trunk/lib/Support/CommandLine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CommandLine.cpp?rev=119842&r1=119841&r2=119842&view=diff
==============================================================================
--- llvm/trunk/lib/Support/CommandLine.cpp (original)
+++ llvm/trunk/lib/Support/CommandLine.cpp Fri Nov 19 15:14:29 2010
@@ -765,6 +765,15 @@
     }
   }
 
+  // Now that we know if -debug is specified, we can use it.
+  // Note that if ReadResponseFiles == true, this must be done before the
+  // memory allocated for the expanded command line is free()d below.
+  DEBUG(dbgs() << "Args: ";
+        for (int i = 0; i < argc; ++i)
+          dbgs() << argv[i] << ' ';
+        dbgs() << '\n';
+       );
+
   // Free all of the memory allocated to the map.  Command line options may only
   // be processed once!
   Opts.clear();
@@ -779,12 +788,6 @@
       free(*i);
   }
 
-  DEBUG(dbgs() << "Args: ";
-        for (int i = 0; i < argc; ++i)
-          dbgs() << argv[i] << ' ';
-        dbgs() << '\n';
-       );
-
   // If we had an error processing our arguments, don't let the program execute
   if (ErrorParsing) exit(1);
 }





More information about the llvm-commits mailing list