diff options
author | Artem Dergachev <artem.dergachev@gmail.com> | 2019-11-21 21:53:50 -0800 |
---|---|---|
committer | Artem Dergachev <artem.dergachev@gmail.com> | 2019-11-21 21:55:58 -0800 |
commit | a3b22da4e0ea84ed5890063926b6f54685c23225 (patch) | |
tree | 84517efa3e08e865cd4538158c799d459a388d28 /clang/lib/Analysis | |
parent | c84c62c50aa8524dbf96217c337f3b5ee4139000 (diff) | |
download | bcm5719-llvm-a3b22da4e0ea84ed5890063926b6f54685c23225.tar.gz bcm5719-llvm-a3b22da4e0ea84ed5890063926b6f54685c23225.zip |
[CFG] Fix a flaky crash in CFGBlock::getLastCondition().
Using an end iterator of an empty CFG block was causing
a garbage pointer dereference.
Differential Revision: https://reviews.llvm.org/D69962
Diffstat (limited to 'clang/lib/Analysis')
-rw-r--r-- | clang/lib/Analysis/CFG.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp index 762b8ecf343..bc21d1c9076 100644 --- a/clang/lib/Analysis/CFG.cpp +++ b/clang/lib/Analysis/CFG.cpp @@ -5879,6 +5879,10 @@ const Expr *CFGBlock::getLastCondition() const { if (succ_size() < 2) return nullptr; + // FIXME: Is there a better condition expression we can return in this case? + if (size() == 0) + return nullptr; + auto StmtElem = rbegin()->getAs<CFGStmt>(); if (!StmtElem) return nullptr; |