Skip to content

Commit d259f72

Browse files
Fix #12888 fuzzing crash in getEnumType() (#6844)
1 parent a62e032 commit d259f72

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

lib/tokenize.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8731,10 +8731,13 @@ void Tokenizer::findGarbageCode() const
87318731
}
87328732
if (Token::Match(tok, "%num%|%bool%|%char%|%str% %num%|%bool%|%char%|%str%") && !Token::Match(tok, "%str% %str%"))
87338733
syntaxError(tok);
8734-
if (Token::Match(tok, "%num%|%bool%|%char%|%str% {") &&
8735-
!(tok->tokType() == Token::Type::eString && Token::simpleMatch(tok->tokAt(-1), "extern")) &&
8736-
!(tok->tokType() == Token::Type::eBoolean && cpp && Token::simpleMatch(tok->tokAt(-1), "requires")))
8737-
syntaxError(tok);
8734+
if (Token::Match(tok, "%num%|%bool%|%char%|%str% {|(")) {
8735+
if (tok->strAt(1) == "(")
8736+
syntaxError(tok);
8737+
else if (!(tok->tokType() == Token::Type::eString && Token::simpleMatch(tok->tokAt(-1), "extern")) &&
8738+
!(tok->tokType() == Token::Type::eBoolean && cpp && Token::simpleMatch(tok->tokAt(-1), "requires")))
8739+
syntaxError(tok);
8740+
}
87388741
if (Token::Match(tok, "%assign% typename|class %assign%"))
87398742
syntaxError(tok);
87408743
if (Token::Match(tok, "%assign% [;)}]") && (!cpp || !Token::simpleMatch(tok->previous(), "operator")))
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
enum{A=0()7=F};

0 commit comments

Comments
 (0)