Fixed crash in AST

This commit is contained in:
Daniel Marjamäki 2020-04-09 17:42:51 +02:00
parent d7af52865d
commit e0c8118c02
2 changed files with 7 additions and 0 deletions

View File

@ -1482,6 +1482,8 @@ static Token * createAstAtToken(Token *tok, bool cpp)
decl = true;
typetok = typetok->next();
}
if (!typetok)
return nullptr;
if (decl && Token::Match(typetok->previous(), "[*&] %var% ="))
tok = typetok;
}

View File

@ -245,6 +245,7 @@ private:
TEST_CASE(garbageCode211); // #8764
TEST_CASE(garbageCode212); // #8765
TEST_CASE(garbageCode213); // #8758
TEST_CASE(garbageCode214);
TEST_CASE(garbageCodeFuzzerClientMode1); // test cases created with the fuzzer client, mode 1
@ -1666,6 +1667,10 @@ private:
ASSERT_THROW(checkCode("{\"\"[(1||)];}"), InternalError);
}
void garbageCode214() {
checkCode("THIS FILE CONTAINS VARIOUS TEXT");
}
void syntaxErrorFirstToken() {
ASSERT_THROW(checkCode("&operator(){[]};"), InternalError); // #7818
ASSERT_THROW(checkCode("*(*const<> (size_t); foo) { } *(*const (size_t)() ; foo) { }"), InternalError); // #6858