diff options
author | Alexey Samsonov <samsonov@google.com> | 2013-11-18 14:53:55 +0000 |
---|---|---|
committer | Alexey Samsonov <samsonov@google.com> | 2013-11-18 14:53:55 +0000 |
commit | 64409ad8e3b360b84349042f14b57f87a5c0ca18 (patch) | |
tree | 97fb4cff2b55902a988ecd4e4ee25797a3ce9889 /lib/Transforms | |
parent | 874081c8fae780138818ad3f706ae75cc7fa9fcd (diff) | |
download | external_llvm-64409ad8e3b360b84349042f14b57f87a5c0ca18.zip external_llvm-64409ad8e3b360b84349042f14b57f87a5c0ca18.tar.gz external_llvm-64409ad8e3b360b84349042f14b57f87a5c0ca18.tar.bz2 |
[ASan] Fix PR17867 - make sure ASan doesn't crash if use-after-scope and use-after-return are combined.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195014 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/Instrumentation/AddressSanitizer.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/lib/Transforms/Instrumentation/AddressSanitizer.cpp index d8c3f8e..d731ec5 100644 --- a/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -426,6 +426,7 @@ struct FunctionStackPoisoner : public InstVisitor<FunctionStackPoisoner> { // Stores a place and arguments of poisoning/unpoisoning call for alloca. struct AllocaPoisonCall { IntrinsicInst *InsBefore; + AllocaInst *AI; uint64_t Size; bool DoPoison; }; @@ -504,7 +505,7 @@ struct FunctionStackPoisoner : public InstVisitor<FunctionStackPoisoner> { AllocaInst *AI = findAllocaForValue(II.getArgOperand(1)); if (!AI) return; bool DoPoison = (ID == Intrinsic::lifetime_end); - AllocaPoisonCall APC = {&II, SizeValue, DoPoison}; + AllocaPoisonCall APC = {&II, AI, SizeValue, DoPoison}; AllocaPoisonCallVec.push_back(APC); } @@ -1523,11 +1524,10 @@ void FunctionStackPoisoner::poisonStack() { bool HavePoisonedAllocas = false; for (size_t i = 0, n = AllocaPoisonCallVec.size(); i < n; i++) { const AllocaPoisonCall &APC = AllocaPoisonCallVec[i]; - IntrinsicInst *II = APC.InsBefore; - AllocaInst *AI = findAllocaForValue(II->getArgOperand(1)); - assert(AI); - IRBuilder<> IRB(II); - poisonAlloca(AI, APC.Size, IRB, APC.DoPoison); + assert(APC.InsBefore); + assert(APC.AI); + IRBuilder<> IRB(APC.InsBefore); + poisonAlloca(APC.AI, APC.Size, IRB, APC.DoPoison); HavePoisonedAllocas |= APC.DoPoison; } |