Skip to content

Commit

Permalink
[dsymutil] Fix stack-use-after-scope
Browse files Browse the repository at this point in the history
The lambda is taking the stack-allocated Verify boolean by reference and
it would go out of scope on the next iteration. Moving it out of the
loop should fix the issue.

Fixes https://bugs.llvm.org/show_bug.cgi?id=43549

llvm-svn: 373683
  • Loading branch information
JDevlieghere committed Oct 4, 2019
1 parent 57b6536 commit 016f6f6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions llvm/tools/dsymutil/dsymutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,9 +520,10 @@ int main(int argc, char **argv) {

// If there is more than one link to execute, we need to generate
// temporary files.
bool NeedsTempFiles =
const bool NeedsTempFiles =
!Options.DumpDebugMap && (Options.OutputFile != "-") &&
(DebugMapPtrsOrErr->size() != 1 || Options.LinkOpts.Update);
const bool Verify = Options.Verify && !Options.LinkOpts.NoOutput;

SmallVector<MachOUtils::ArchAndFile, 4> TempFiles;
std::atomic_char AllOK(1);
Expand Down Expand Up @@ -577,7 +578,6 @@ int main(int argc, char **argv) {
}
}

const bool Verify = Options.Verify && !Options.LinkOpts.NoOutput;
auto LinkLambda = [&, OutputFile](std::shared_ptr<raw_fd_ostream> Stream,
LinkOptions Options) {
AllOK.fetch_and(
Expand Down

0 comments on commit 016f6f6

Please sign in to comment.