Skip to content

Commit c9cb62f

Browse files
Fix #14897 fuzzing crash (null-pointer-use) in SymbolDatabase::createSymbolDatabaseSetScopePointers() (#8703)
1 parent b839fa5 commit c9cb62f

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

lib/symboldatabase.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,14 @@ const Token* SymbolDatabase::isEnumDefinition(const Token* tok)
138138
if (tok->str() == "{")
139139
return tok;
140140
tok = tok->next(); // skip ':'
141-
while (Token::Match(tok, "%name%|::"))
141+
bool hasType = false;
142+
while (Token::Match(tok, "%name%|::")) {
143+
if (tok->isName())
144+
hasType = true;
142145
tok = tok->next();
146+
}
147+
if (!hasType)
148+
throw InternalError(tok, "SymbolDatabase bailout; invalid enum", InternalError::SYNTAX);
143149
return Token::simpleMatch(tok, "{") ? tok : nullptr;
144150
}
145151

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
enumf:{};

0 commit comments

Comments
 (0)