summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/CommandLine.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2010-11-19 21:14:29 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2010-11-19 21:14:29 +0000
commitcf14a382ec42f83ff0b69ae342979db7bd6da944 (patch)
treee966c6335a406c73f2bc4ce4120e01d01a0bcb3a /llvm/lib/Support/CommandLine.cpp
parentd6e5c9f2fe0db62957b0e34bf661fa66a7915a4d (diff)
downloadbcm5719-llvm-cf14a382ec42f83ff0b69ae342979db7bd6da944.tar.gz
bcm5719-llvm-cf14a382ec42f83ff0b69ae342979db7bd6da944.zip
Fix a use after free. Patch by Frits van Bommel.
llvm-svn: 119842
Diffstat (limited to 'llvm/lib/Support/CommandLine.cpp')
-rw-r--r--llvm/lib/Support/CommandLine.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp
index ae66110ded6..38ef0849616 100644
--- a/llvm/lib/Support/CommandLine.cpp
+++ b/llvm/lib/Support/CommandLine.cpp
@@ -765,6 +765,15 @@ void cl::ParseCommandLineOptions(int argc, char **argv,
}
}
+ // 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 @@ void cl::ParseCommandLineOptions(int argc, char **argv,
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);
}
OpenPOWER on IntegriCloud