summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis
diff options
context:
space:
mode:
authorArtem Dergachev <artem.dergachev@gmail.com>2019-11-21 21:53:50 -0800
committerArtem Dergachev <artem.dergachev@gmail.com>2019-11-21 21:55:58 -0800
commita3b22da4e0ea84ed5890063926b6f54685c23225 (patch)
tree84517efa3e08e865cd4538158c799d459a388d28 /clang/lib/Analysis
parentc84c62c50aa8524dbf96217c337f3b5ee4139000 (diff)
downloadbcm5719-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.cpp4
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;
OpenPOWER on IntegriCloud