Skip to content
This repository has been archived by the owner on Apr 23, 2020. It is now read-only.

Commit

Permalink
[dsymutil] Fix heap-use-after-free related to the LinkOptions.
Browse files Browse the repository at this point in the history
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@367635 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
JDevlieghere committed Aug 1, 2019
1 parent 884000e commit 3c182ac
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions tools/dsymutil/dsymutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand All @@ -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();
Expand Down

0 comments on commit 3c182ac

Please sign in to comment.