Fix crash on garbage code (#3834)
This commit is contained in:
parent
907218254e
commit
52f549fa87
|
@ -4286,7 +4286,10 @@ void Tokenizer::setVarIdPass2()
|
||||||
while (Token::Match(tokStart, ":: %name%") || tokStart->str() == "<") {
|
while (Token::Match(tokStart, ":: %name%") || tokStart->str() == "<") {
|
||||||
if (tokStart->str() == "<") {
|
if (tokStart->str() == "<") {
|
||||||
// skip the template part
|
// skip the template part
|
||||||
tokStart = tokStart->findClosingBracket()->next();
|
const Token* closeTok = tokStart->findClosingBracket();
|
||||||
|
if (!closeTok)
|
||||||
|
syntaxError(tok);
|
||||||
|
tokStart = closeTok->next();
|
||||||
} else {
|
} else {
|
||||||
classnameTokens.push_back(tokStart->next());
|
classnameTokens.push_back(tokStart->next());
|
||||||
tokStart = tokStart->tokAt(2);
|
tokStart = tokStart->tokAt(2);
|
||||||
|
|
|
@ -250,6 +250,7 @@ private:
|
||||||
TEST_CASE(garbageCode218); // #8763
|
TEST_CASE(garbageCode218); // #8763
|
||||||
TEST_CASE(garbageCode219); // #10101
|
TEST_CASE(garbageCode219); // #10101
|
||||||
TEST_CASE(garbageCode220); // #6832
|
TEST_CASE(garbageCode220); // #6832
|
||||||
|
TEST_CASE(garbageCode221);
|
||||||
|
|
||||||
TEST_CASE(garbageCodeFuzzerClientMode1); // test cases created with the fuzzer client, mode 1
|
TEST_CASE(garbageCodeFuzzerClientMode1); // test cases created with the fuzzer client, mode 1
|
||||||
|
|
||||||
|
@ -1704,6 +1705,9 @@ private:
|
||||||
void garbageCode220() { // #6832
|
void garbageCode220() { // #6832
|
||||||
ASSERT_THROW(checkCode("(){(){{()}}return;{switch()0 case(){}break;l:()}}\n"), InternalError); // don't crash
|
ASSERT_THROW(checkCode("(){(){{()}}return;{switch()0 case(){}break;l:()}}\n"), InternalError); // don't crash
|
||||||
}
|
}
|
||||||
|
void garbageCode221() {
|
||||||
|
ASSERT_THROW(checkCode("struct A<0<;\n"), InternalError); // don't crash
|
||||||
|
}
|
||||||
|
|
||||||
void syntaxErrorFirstToken() {
|
void syntaxErrorFirstToken() {
|
||||||
ASSERT_THROW(checkCode("&operator(){[]};"), InternalError); // #7818
|
ASSERT_THROW(checkCode("&operator(){[]};"), InternalError); // #7818
|
||||||
|
|
Loading…
Reference in New Issue