diff options
author | Amara Emerson <amara@apple.com> | 2020-09-02 23:17:48 -0700 |
---|---|---|
committer | Amara Emerson <amara@apple.com> | 2020-09-03 00:08:48 -0700 |
commit | 2878ecc90f1f22cf0b96c04a4124122db008a2a9 (patch) | |
tree | e86712cbb698e4d0c82d8b6a5b574b170b8b37db /llvm/lib/CodeGen/StackProtector.cpp | |
parent | 9e9e6e698d8ef5dc5b7576058f2022aab2534a52 (diff) | |
download | llvm-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.cpp | 3 |
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: |