Skip to content

Commit 82f05c8

Browse files
Fix #12544 Crash in getDeallocFuncInfo() (cppcheck-opensource#6187)
1 parent d8e4914 commit 82f05c8

3 files changed

Lines changed: 7 additions & 1 deletion

File tree

lib/tokenlist.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1752,6 +1752,11 @@ static Token * createAstAtToken(Token *tok)
17521752
return endToken->previous();
17531753
}
17541754

1755+
if (cpp && ((!tok->previous() && tok->str() == "::") || Token::Match(tok->previous(), "[;{}] ::"))) {
1756+
AST_state state(cpp);
1757+
compileExpression(tok, state);
1758+
}
1759+
17551760
return tok;
17561761
}
17571762

test/testfunctions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ class TestFunctions : public TestFixture {
411411
"{\n"
412412
" ::getpwent();\n"
413413
"}");
414-
ASSERT_EQUALS("[test.cpp:3]: (warning) Return value of function getpwent() is not used.\n"
414+
ASSERT_EQUALS("[test.cpp:3]: (warning) Return value of function ::getpwent() is not used.\n"
415415
"[test.cpp:3]: (portability) Non reentrant function 'getpwent' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getpwent_r'.\n", errout_str());
416416

417417
// Be quiet on function definitions

test/testtokenize.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6541,6 +6541,7 @@ class TestTokenizer : public TestFixture {
65416541
ASSERT_EQUALS("PT.(", testAst("P->~T();")); // <- The "T" token::function() will be a destructor
65426542
ASSERT_EQUALS("double&(4[", testAst("void f(double(&)[4]) {}"));
65436543
ASSERT_EQUALS("voidu*", testAst("int* g ( void* (f) (void*), void* u);")); // #12475
6544+
ASSERT_EQUALS("f::(", testAst("::f();")); // #12544
65446545
}
65456546

65466547
void asttemplate() { // uninstantiated templates will have <,>,etc..

0 commit comments

Comments
 (0)