diff --git a/lib/checkbool.cpp b/lib/checkbool.cpp index 7bcce7ae3..851206fb4 100644 --- a/lib/checkbool.cpp +++ b/lib/checkbool.cpp @@ -459,6 +459,7 @@ void CheckBool::pointerArithBoolCond(const Token *tok) return; if (tok->astOperand1() && + tok->astOperand2() && tok->astOperand1()->isName() && tok->astOperand1()->variable() && tok->astOperand1()->variable()->isPointer() && diff --git a/test/testgarbage.cpp b/test/testgarbage.cpp index f884c36e4..8ef22d0d5 100644 --- a/test/testgarbage.cpp +++ b/test/testgarbage.cpp @@ -185,6 +185,7 @@ private: TEST_CASE(garbageCode133); TEST_CASE(garbageCode134); TEST_CASE(garbageCode135); // #4994 + TEST_CASE(garbageCode136); // #7033 TEST_CASE(garbageValueFlow); TEST_CASE(garbageSymbolDatabase); @@ -1073,6 +1074,10 @@ private: "long b = 2 ;"); } + void garbageCode136() { // #7033 + checkCode("{ } () { void f() { node_t * n; for (; -n) {} } } { }"); + } + void garbageValueFlow() { // #6089