Fixed #9069 (crash on invalid code: ' x= y{ } name5 ')
Credit to OSS-Fuzz for reporting this!
This commit is contained in:
parent
4a45655bc2
commit
0f6a90c595
|
@ -9052,9 +9052,14 @@ void Tokenizer::findGarbageCode() const
|
|||
"typedef",
|
||||
"while"};
|
||||
for (const Token *tok = tokens(); tok; tok = tok->next()) {
|
||||
if (Token::Match(tok, "%name% %name%") && nonConsecutiveKeywords.count(tok->str()) == 1 && nonConsecutiveKeywords.count(tok->next()->str()) == 1)
|
||||
if (!tok->isName() || nonConsecutiveKeywords.count(tok->str()) == 0)
|
||||
continue;
|
||||
if (Token::Match(tok, "%name% %name%") && nonConsecutiveKeywords.count(tok->next()->str()) == 1)
|
||||
syntaxError(tok);
|
||||
if (Token::Match(tok, "%op% %name%") && nonConsecutiveKeywords.count(tok->next()->str()) == 1)
|
||||
const Token *prev = tok;
|
||||
while (prev && prev->isName())
|
||||
prev = prev->previous();
|
||||
if (Token::Match(prev, "%op%|%num%|%str%|%char%"))
|
||||
syntaxError(tok);
|
||||
}
|
||||
|
||||
|
|
|
@ -1658,6 +1658,7 @@ private:
|
|||
ASSERT_THROW(checkCode("void f(){x='0'++'0'(return)[];}"), InternalError); // #9063
|
||||
ASSERT_THROW(checkCode("void f() { x= 'x' > typedef name5 | ( , ;){ } (); }"), InternalError); // #9067
|
||||
ASSERT_THROW(checkCode("void f() { x= {}( ) ( 'x')[ ] (); }"), InternalError); // #9068
|
||||
ASSERT_THROW(checkCode("void f() { x= y{ } name5 y[ ] + y ^ name5 ^ name5 for ( ( y y y && y y y && name5 ++ int )); }"), InternalError); // #9069
|
||||
}
|
||||
|
||||
void enumTrailingComma() {
|
||||
|
|
Loading…
Reference in New Issue