diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 7767dcd14..315802109 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -5736,6 +5736,9 @@ struct ConditionHandler { std::swap(thenValues, elseValues); } + if (!condTop) + return; + if (Token::simpleMatch(condTop, "?")) { Token* colon = condTop->astOperand2(); forward(colon->astOperand1(), cond.vartok, thenValues, tokenlist, settings); diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index 70aa168ad..fc646b711 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -6442,6 +6442,9 @@ private: " void f(std::array& a);\n" "};\n"; valueOfTok(code, "a"); + + code = "void f(const char * const x) { !!system(x); }\n"; + valueOfTok(code, "x"); } void valueFlowHang() {