Skip to content

Commit

Permalink
Fix #12864, #12865 fuzzing crashes (#6547)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github authored Jun 26, 2024
1 parent 1668b0b commit 096174a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,9 @@ namespace {

Token* const tok4 = useAfterVarRange ? insertTokens(after->previous(), mRangeAfterVar)->next() : tok3->next();

if (tok->next() == tok4)
throw InternalError(tok, "Failed to simplify typedef. Is the code valid?");

tok->deleteThis();

// Unsplit variable declarations
Expand Down Expand Up @@ -8695,6 +8698,10 @@ void Tokenizer::findGarbageCode() const
}
if (Token::Match(tok, "%num%|%bool%|%char%|%str% %num%|%bool%|%char%|%str%") && !Token::Match(tok, "%str% %str%"))
syntaxError(tok);
if (Token::Match(tok, "%num%|%bool%|%char%|%str% {") &&
!(tok->tokType() == Token::Type::eString && Token::simpleMatch(tok->tokAt(-1), "extern")) &&
!(tok->tokType() == Token::Type::eBoolean && cpp && Token::simpleMatch(tok->tokAt(-1), "requires")))
syntaxError(tok);
if (Token::Match(tok, "%assign% typename|class %assign%"))
syntaxError(tok);
if (Token::Match(tok, "%assign% [;)}]") && (!cpp || !Token::simpleMatch(tok->previous(), "operator")))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
typedef const C;C(public C<i)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
enum{a=1{}=d};

0 comments on commit 096174a

Please sign in to comment.