Skip to content

Commit

Permalink
Fix #13493 fuzzing crash (stack overflow) in CheckNullPointer::nullPo…
Browse files Browse the repository at this point in the history
…interByDeRefAndCheck() (#7160)
  • Loading branch information
chrchr-github authored Jan 2, 2025
1 parent 5bbde51 commit 7a40fbc
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
2 changes: 2 additions & 0 deletions lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8765,6 +8765,8 @@ void Tokenizer::findGarbageCode() const
}
if (Token::Match(tok, "[{,] . %name%") && !Token::Match(tok->tokAt(3), "[.=[{]"))
syntaxError(tok->next());
if (Token::Match(tok, "%name% %op% %name%") && !tok->isKeyword() && tok->next()->isIncDecOp())
syntaxError(tok->next());
if (Token::Match(tok, "[!|+-/%^~] )|]"))
syntaxError(tok);
if (Token::Match(tok, "==|!=|<=|>= %comp%") && tok->strAt(-1) != "operator")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
n(){o?5:t++m}
2 changes: 1 addition & 1 deletion test/testother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5111,7 +5111,7 @@ class TestOther : public TestFixture {
" {\n"
" case 2:\n"
" y |= z;\n"
" z++\n"
" z++;\n"
" default:\n"
" y |= z;\n"
" break;\n"
Expand Down
6 changes: 3 additions & 3 deletions test/teststl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1386,7 +1386,7 @@ class TestStl : public TestFixture {
" std::vector<int>::const_iterator it;\n"
" it = a.begin();\n"
" while (it!=a.end())\n"
" v++it;\n"
" ++it;\n"
" it = t.begin();\n"
" while (it!=t.end())\n"
" ++it;\n"
Expand All @@ -1402,9 +1402,9 @@ class TestStl : public TestFixture {
" else\n"
" it = t.begin();\n"
" while (z && it!=a.end())\n"
" v++it;\n"
" ++it;\n"
" while (!z && it!=t.end())\n"
" v++it;\n"
" ++it;\n"
"}");
ASSERT_EQUALS("", errout_str());
}
Expand Down

0 comments on commit 7a40fbc

Please sign in to comment.