Skip to content

Commit 30e8814

Browse files
Fix #12255 Crash in executeMultiCondition() (#5752)
1 parent faafd93 commit 30e8814

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

lib/programmemory.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,6 +1341,8 @@ namespace {
13411341

13421342
for (const auto& p : *pm) {
13431343
const Token* tok = p.first.tok;
1344+
if (!tok)
1345+
continue;
13441346
const ValueFlow::Value& value = p.second;
13451347

13461348
if (tok->str() == expr->str() && !astHasExpr(tok, expr->exprId())) {

test/testvalueflow.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7275,6 +7275,17 @@ class TestValueFlow : public TestFixture {
72757275
" if (a && b) {}\n"
72767276
"}\n";
72777277
valueOfTok(code, "a");
7278+
7279+
code = "void g(const char* fmt, ...);\n" // #12255
7280+
"void f(const char* fmt, const char* msg) {\n"
7281+
" const char* p = msg;\n"
7282+
" g(\"%s\", msg);\n"
7283+
"}\n"
7284+
"void g(const char* fmt, ...) {\n"
7285+
" const char* q = fmt;\n"
7286+
" if (*q > 0 && *q < 100) {}\n"
7287+
"}\n";
7288+
valueOfTok(code, "&&");
72787289
}
72797290

72807291
void valueFlowHang() {

0 commit comments

Comments
 (0)