diff options
author | Richard Trieu <rtrieu@google.com> | 2013-04-30 22:45:10 +0000 |
---|---|---|
committer | Richard Trieu <rtrieu@google.com> | 2013-04-30 22:45:10 +0000 |
commit | 624c2ebcbbbe73987e593bdf698a517775b43f44 (patch) | |
tree | becfb0ad83974561bb9b4d5372bc11f76147fab2 /llvm/lib/Transforms/Utils/InlineFunction.cpp | |
parent | ab067ae8b00e4d6eea68e94f2bc06e126d538bd8 (diff) | |
download | llvm-624c2ebcbbbe73987e593bdf698a517775b43f44.zip llvm-624c2ebcbbbe73987e593bdf698a517775b43f44.tar.gz llvm-624c2ebcbbbe73987e593bdf698a517775b43f44.tar.bz2 |
Fix a use after free. RI is freed before the call to getDebugLoc(). To
prevent this, capture the location before RI is freed.
llvm-svn: 180824
Diffstat (limited to 'llvm/lib/Transforms/Utils/InlineFunction.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/InlineFunction.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp index 019f40d..dabb67b 100644 --- a/llvm/lib/Transforms/Utils/InlineFunction.cpp +++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp @@ -853,11 +853,12 @@ bool llvm::InlineFunction(CallSite CS, InlineFunctionInfo &IFI, // Add a branch to the merge points and remove return instructions. - ReturnInst *RI; + DebugLoc Loc; for (unsigned i = 0, e = Returns.size(); i != e; ++i) { - RI = Returns[i]; + ReturnInst *RI = Returns[i]; BranchInst* BI = BranchInst::Create(AfterCallBB, RI); - BI->setDebugLoc(RI->getDebugLoc()); + Loc = RI->getDebugLoc(); + BI->setDebugLoc(Loc); RI->eraseFromParent(); } // We need to set the debug location to *somewhere* inside the @@ -865,7 +866,7 @@ bool llvm::InlineFunction(CallSite CS, InlineFunctionInfo &IFI, // instruction will at least be associated with the right // function. if (CreatedBranchToNormalDest) - CreatedBranchToNormalDest->setDebugLoc(RI->getDebugLoc()); + CreatedBranchToNormalDest->setDebugLoc(Loc); } else if (!Returns.empty()) { // Otherwise, if there is exactly one return value, just replace anything // using the return value of the call with the computed value. |