Fixed #9063 (Crash on invalid code: x='0' ++ '0' ( return)[ ];)

This commit is contained in:
Daniel Marjamäki 2019-03-25 15:29:23 +01:00
parent 10fcf731d9
commit 49e2f9d551
2 changed files with 7 additions and 0 deletions

View File

@ -8508,6 +8508,12 @@ void Tokenizer::findGarbageCode() const
unknownMacroError(tok->linkAt(1)->previous()); unknownMacroError(tok->linkAt(1)->previous());
} }
// Assign/increment/decrement literal
for (const Token *tok = tokens(); tok; tok = tok->next()) {
if (Token::Match(tok,"%num%|%str%|%char% %assign%|++|--"))
syntaxError(tok);
}
for (const Token *tok = tokens(); tok; tok = tok->next()) { for (const Token *tok = tokens(); tok; tok = tok->next()) {
if (Token::Match(tok, "if|while|for|switch")) { // if|while|for|switch (EXPR) { ... } if (Token::Match(tok, "if|while|for|switch")) { // if|while|for|switch (EXPR) { ... }
if (tok->previous() && !Token::Match(tok->previous(), "%name%|:|;|{|}|(|)|,")) if (tok->previous() && !Token::Match(tok->previous(), "%name%|:|;|{|}|(|)|,"))

View File

@ -1654,6 +1654,7 @@ private:
void syntaxErrorFuzzerCliType1() { void syntaxErrorFuzzerCliType1() {
ASSERT_THROW(checkCode("void f(){x=0,return return''[]()}"), InternalError); ASSERT_THROW(checkCode("void f(){x=0,return return''[]()}"), InternalError);
ASSERT_THROW(checkCode("void f(){x='0'++'0'(return)[];}"), InternalError); // #9063
} }
void enumTrailingComma() { void enumTrailingComma() {