Skip to content

Commit

Permalink
CheckLeakAutoVar: fix crash on unknown macro
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Jan 5, 2024
1 parent 6ef3224 commit e0c2699
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/checkleakautovar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1046,10 +1046,10 @@ void CheckLeakAutoVar::functionCall(const Token *tokName, const Token *tokOpenin
changeAllocStatus(varInfo, sp_allocation, vtok, vtok);
} else {
const Token* const nextArg = funcArg->nextArgument();
do {
while (arg && ((nextArg && arg != nextArg) || (!nextArg && arg != tokOpeningPar->link()))) {
checkTokenInsideExpression(arg, varInfo, /*inFuncCall*/ isLeakIgnore);
arg = arg->next();
} while ((nextArg && arg != nextArg) || (!nextArg && arg != tokOpeningPar->link()));
}
}
// TODO: check each token in argument expression (could contain multiple variables)
argNr++;
Expand Down
5 changes: 5 additions & 0 deletions test/testleakautovar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,11 @@ class TestLeakAutoVar : public TestFixture {
ASSERT_EQUALS("[test.c:4]: (error) Dereferencing 'p' after it is deallocated / released\n"
"[test.c:7] -> [test.c:8]: (error) Returning/dereferencing 'p' after it is deallocated / released\n",
errout.str());

check("void f() {\n"
" FOREACH(callables, ());\n"
"}\n");
ASSERT_EQUALS("[test.c:2]: (information) --check-library: Function FOREACH() should have <noreturn> configuration\n", errout.str()); // don't crash
}

void doublefree1() { // #3895
Expand Down

0 comments on commit e0c2699

Please sign in to comment.