summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2016-05-16 11:25:06 +0200
committerNoel Grandin <noel@peralex.com>2016-05-16 11:25:34 +0200
commit42801672f0acc3b2ffbc30602d881b43e62d07cf (patch)
tree4a730ffff86bfc29810899dee23791f4cffc6ddd
parentd9bdc157b43ce412ad4689ee78b81068b1224d30 (diff)
fix null pointer crash in loplugin:commaoperator
Change-Id: Ie077ed9a8f200b39da25938b35a3622e52cc5110
-rw-r--r--compilerplugins/clang/commaoperator.cxx26
1 files changed, 14 insertions, 12 deletions
diff --git a/compilerplugins/clang/commaoperator.cxx b/compilerplugins/clang/commaoperator.cxx
index 4df9cea9b435..3e5df3d6e5d9 100644
--- a/compilerplugins/clang/commaoperator.cxx
+++ b/compilerplugins/clang/commaoperator.cxx
@@ -44,20 +44,22 @@ bool CommaOperator::VisitBinaryOperator(const BinaryOperator* binaryOp)
return true;
}
const Stmt* parent = parentStmt(binaryOp);
- if (isa<ParenExpr>(parent)) {
- return true;
- }
- if (isa<BinaryOperator>(parent)) {
- return true;
- }
- if (isa<ForStmt>(parent)) {
- return true;
- }
- if (isa<ExprWithCleanups>(parent)) {
- const Stmt* parent2 = parentStmt(parent);
- if (isa<ForStmt>(parent2)) {
+ if (parent != nullptr) {
+ if (isa<ParenExpr>(parent)) {
return true;
}
+ if (isa<BinaryOperator>(parent)) {
+ return true;
+ }
+ if (isa<ForStmt>(parent)) {
+ return true;
+ }
+ if (isa<ExprWithCleanups>(parent)) {
+ const Stmt* parent2 = parentStmt(parent);
+ if (isa<ForStmt>(parent2)) {
+ return true;
+ }
+ }
}
// parent->dump();
report(