[llvm] r367635 - [dsymutil] Fix heap-use-after-free related to the LinkOptions.
Jonas Devlieghere via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 1 16:37:33 PDT 2019
Author: jdevlieghere
Date: Thu Aug 1 16:37:33 2019
New Revision: 367635
URL: http://llvm.org/viewvc/llvm-project?rev=367635&view=rev
Log:
[dsymutil] Fix heap-use-after-free related to the LinkOptions.
In r367348, I changed dsymutil to pass the LinkOptions by value isntead
of by const reference. However, the options were still captured by
reference in the LinkLambda. This patch fixes that by passing them in by
value.
Modified:
llvm/trunk/tools/dsymutil/dsymutil.cpp
Modified: llvm/trunk/tools/dsymutil/dsymutil.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/dsymutil/dsymutil.cpp?rev=367635&r1=367634&r2=367635&view=diff
==============================================================================
--- llvm/trunk/tools/dsymutil/dsymutil.cpp (original)
+++ llvm/trunk/tools/dsymutil/dsymutil.cpp Thu Aug 1 16:37:33 2019
@@ -591,9 +591,10 @@ int main(int argc, char **argv) {
}
}
- auto LinkLambda = [&,
- OutputFile](std::shared_ptr<raw_fd_ostream> Stream) {
- AllOK.fetch_and(linkDwarf(*Stream, BinHolder, *Map, *OptionsOrErr));
+ auto LinkLambda = [&, OutputFile](std::shared_ptr<raw_fd_ostream> Stream,
+ LinkOptions Options) {
+ AllOK.fetch_and(
+ linkDwarf(*Stream, BinHolder, *Map, std::move(Options)));
Stream->flush();
if (Verify && !NoOutput)
AllOK.fetch_and(verify(OutputFile, Map->getTriple().getArchName()));
@@ -603,9 +604,9 @@ int main(int argc, char **argv) {
// out the (significantly smaller) stack when using threads. We don't
// want this limitation when we only have a single thread.
if (ThreadCount == 1)
- LinkLambda(OS);
+ LinkLambda(OS, *OptionsOrErr);
else
- Threads.async(LinkLambda, OS);
+ Threads.async(LinkLambda, OS, *OptionsOrErr);
}
Threads.wait();
More information about the llvm-commits
mailing list