aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/StackProtector.cpp
diff options
context:
space:
mode:
authorAmara Emerson <amara@apple.com>2020-09-02 23:17:48 -0700
committerAmara Emerson <amara@apple.com>2020-09-03 00:08:48 -0700
commit2878ecc90f1f22cf0b96c04a4124122db008a2a9 (patch)
treee86712cbb698e4d0c82d8b6a5b574b170b8b37db /llvm/lib/CodeGen/StackProtector.cpp
parent9e9e6e698d8ef5dc5b7576058f2022aab2534a52 (diff)
downloadllvm-2878ecc90f1f22cf0b96c04a4124122db008a2a9.zip
llvm-2878ecc90f1f22cf0b96c04a4124122db008a2a9.tar.gz
llvm-2878ecc90f1f22cf0b96c04a4124122db008a2a9.tar.bz2
[StackProtector] Fix crash with vararg due to not checking LocationSize validity.
Differential Revision: https://reviews.llvm.org/D87074
Diffstat (limited to 'llvm/lib/CodeGen/StackProtector.cpp')
-rw-r--r--llvm/lib/CodeGen/StackProtector.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/StackProtector.cpp b/llvm/lib/CodeGen/StackProtector.cpp
index e246c2e..3d961af 100644
--- a/llvm/lib/CodeGen/StackProtector.cpp
+++ b/llvm/lib/CodeGen/StackProtector.cpp
@@ -170,7 +170,8 @@ bool StackProtector::HasAddressTaken(const Instruction *AI,
// If this instruction accesses memory make sure it doesn't access beyond
// the bounds of the allocated object.
Optional<MemoryLocation> MemLoc = MemoryLocation::getOrNone(I);
- if (MemLoc.hasValue() && MemLoc->Size.getValue() > AllocSize)
+ if (MemLoc.hasValue() && MemLoc->Size.hasValue() &&
+ MemLoc->Size.getValue() > AllocSize)
return true;
switch (I->getOpcode()) {
case Instruction::Store: