Fixed #8386 (syntax error not found (segmentation fault)) (#1081)

This commit is contained in:
IOBYTE 2018-02-03 09:50:05 -05:00 committed by Daniel Marjamäki
parent 2e5d7a8391
commit d721c6aca5
2 changed files with 6 additions and 1 deletions

View File

@ -97,7 +97,7 @@ const Token * Tokenizer::isFunctionHead(const Token *tok, const std::string &end
tok = tok->next(); tok = tok->next();
if (tok->str() == ")") if (tok->str() == ")")
tok = tok->next(); tok = tok->next();
while (tok && tok->str() == "[") while (tok && tok->str() == "[" && tok->link())
tok = tok->link()->next(); tok = tok->link()->next();
return (tok && endsWith.find(tok->str()) != std::string::npos) ? tok : nullptr; return (tok && endsWith.find(tok->str()) != std::string::npos) ? tok : nullptr;
} }

View File

@ -222,6 +222,7 @@ private:
TEST_CASE(garbageCode189); // #8317 TEST_CASE(garbageCode189); // #8317
TEST_CASE(garbageCode190); // #8307 TEST_CASE(garbageCode190); // #8307
TEST_CASE(garbageCode191); // #8333 TEST_CASE(garbageCode191); // #8333
TEST_CASE(garbageCode192); // #8386 (segmentation fault)
TEST_CASE(garbageCodeFuzzerClientMode1); // test cases created with the fuzzer client, mode 1 TEST_CASE(garbageCodeFuzzerClientMode1); // test cases created with the fuzzer client, mode 1
@ -1475,6 +1476,10 @@ private:
checkCode("struct A { int f ( char ) ; } ;"); checkCode("struct A { int f ( char ) ; } ;");
} }
void garbageCode192() { // #8386 (segmentation fault)
ASSERT_THROW(checkCode("{(()[((0||0xf||))]0[])}"), InternalError);
}
void syntaxErrorFirstToken() { void syntaxErrorFirstToken() {
ASSERT_THROW(checkCode("&operator(){[]};"), InternalError); // #7818 ASSERT_THROW(checkCode("&operator(){[]};"), InternalError); // #7818
ASSERT_THROW(checkCode("*(*const<> (size_t); foo) { } *(*const (size_t)() ; foo) { }"), InternalError); // #6858 ASSERT_THROW(checkCode("*(*const<> (size_t); foo) { } *(*const (size_t)() ; foo) { }"), InternalError); // #6858