Skip to content

Fix #14883 fuzzing crash (null-pointer-use) in Tokenizer::findGarbageCode()#8692

Open
chrchr-github wants to merge 3 commits into
cppcheck-opensource:mainfrom
chrchr-github:chr_14883
Open

Fix #14883 fuzzing crash (null-pointer-use) in Tokenizer::findGarbageCode()#8692
chrchr-github wants to merge 3 commits into
cppcheck-opensource:mainfrom
chrchr-github:chr_14883

Conversation

@chrchr-github

Copy link
Copy Markdown
Collaborator

No description provided.

Comment thread lib/tokenize.cpp
@@ -8962,6 +8962,8 @@ void Tokenizer::findGarbageCode() const
const Token* const endTok = tok->linkAt(1);
for (tok = tok->tokAt(2); tok != endTok; tok = tok->next()) {
if (const Token* lam = findLambdaEndTokenWithoutAST(tok)) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If tok is nullptr this call would "fail" and thus we would still deref it below. IS this something to address or should we wait for fuzzed variant which will actually trigger that?

@chrchr-github chrchr-github Jul 3, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be fine for now since tok cannot be set to endTok anywhere else (findLambdaEndTokenWithoutAST() returns the Token after }).
precedes() cannot be used because token indices don't exist yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants