aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/InlineFunction.cpp
diff options
context:
space:
mode:
authorRichard Trieu <rtrieu@google.com>2013-04-30 22:45:10 +0000
committerRichard Trieu <rtrieu@google.com>2013-04-30 22:45:10 +0000
commit8e229c24ed8b8a9a3866947a709e616b33780f1f (patch)
treef347eb054178074c0370a8804f209023d4f8ca8e /lib/Transforms/Utils/InlineFunction.cpp
parentcd6c57917db22a3913a2cdbadfa79fed3547bdec (diff)
Fix a use after free. RI is freed before the call to getDebugLoc(). To
prevent this, capture the location before RI is freed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180824 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/InlineFunction.cpp')
-rw-r--r--lib/Transforms/Utils/InlineFunction.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/Transforms/Utils/InlineFunction.cpp b/lib/Transforms/Utils/InlineFunction.cpp
index 019f40dda8..dabb67b921 100644
--- a/lib/Transforms/Utils/InlineFunction.cpp
+++ b/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.