From: Jonas Devlieghere Date: Fri, 4 Oct 2019 00:39:48 +0000 (+0000) Subject: [dsymutil] Fix stack-use-after-scope X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=42beceb5d45daef6c19d196ef26adbcb0fb0d0ac;p=llvm [dsymutil] Fix stack-use-after-scope 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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373683 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/tools/dsymutil/dsymutil.cpp b/tools/dsymutil/dsymutil.cpp index fe69abed0a8..983e86808e7 100644 --- a/tools/dsymutil/dsymutil.cpp +++ b/tools/dsymutil/dsymutil.cpp @@ -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 TempFiles; std::atomic_char AllOK(1); @@ -577,7 +578,6 @@ int main(int argc, char **argv) { } } - const bool Verify = Options.Verify && !Options.LinkOpts.NoOutput; auto LinkLambda = [&, OutputFile](std::shared_ptr Stream, LinkOptions Options) { AllOK.fetch_and(