Skip to content

Commit 096174a

Browse files
Fix #12864, #12865 fuzzing crashes (#6547)
1 parent 1668b0b commit 096174a

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

lib/tokenize.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,9 @@ namespace {
910910

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

913+
if (tok->next() == tok4)
914+
throw InternalError(tok, "Failed to simplify typedef. Is the code valid?");
915+
913916
tok->deleteThis();
914917

915918
// Unsplit variable declarations
@@ -8695,6 +8698,10 @@ void Tokenizer::findGarbageCode() const
86958698
}
86968699
if (Token::Match(tok, "%num%|%bool%|%char%|%str% %num%|%bool%|%char%|%str%") && !Token::Match(tok, "%str% %str%"))
86978700
syntaxError(tok);
8701+
if (Token::Match(tok, "%num%|%bool%|%char%|%str% {") &&
8702+
!(tok->tokType() == Token::Type::eString && Token::simpleMatch(tok->tokAt(-1), "extern")) &&
8703+
!(tok->tokType() == Token::Type::eBoolean && cpp && Token::simpleMatch(tok->tokAt(-1), "requires")))
8704+
syntaxError(tok);
86988705
if (Token::Match(tok, "%assign% typename|class %assign%"))
86998706
syntaxError(tok);
87008707
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+
typedef const C;C(public C<i)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
enum{a=1{}=d};

0 commit comments

Comments
 (0)