#7020 segmentation fault (invalid code) in Tokenizer::simplifyTypedef. #7021 segmentation fault (invalid code) in Tokenizer::simplifyEnum

This commit is contained in:
Alexander Mai 2015-10-03 10:47:23 +02:00
parent 6f72b97e96
commit 27f72d7ae0
2 changed files with 17 additions and 1 deletions

View File

@ -1098,6 +1098,8 @@ void Tokenizer::simplifyTypedef()
if (func->previous()->str() == "operator")
func = func->previous();
if (!func->previous()) // #7020
syntaxError(func);
// check for qualifier
if (func->previous()->str() == "::") {
// check for available and matching class name
@ -7633,6 +7635,8 @@ void Tokenizer::simplifyEnum()
if (enumtok == ev->end)
break;
}
if (!enumtok) // #7021
syntaxError(nullptr);
if (enumtok->isOp()) {
hasOp = true;
break;

View File

@ -168,6 +168,8 @@ private:
TEST_CASE(garbageCode126); // #6997
TEST_CASE(garbageCode127); // #6667
TEST_CASE(garbageCode128); // #7018
TEST_CASE(garbageCode129); // #7020
TEST_CASE(garbageCode130); // #7021
TEST_CASE(garbageValueFlow);
TEST_CASE(garbageSymbolDatabase);
@ -968,7 +970,17 @@ private:
void garbageCode128() {
ASSERT_THROW(checkCode("enum { FOO = ( , ) } {{ }} enum {{ FOO << = } ( ) } {{ }} ;"),
InternalError);
InternalError);
}
void garbageCode129() {
ASSERT_THROW(checkCode("operator - ( { } typedef typename x ; ( ) ) { ( { { ( ( ) ) } ( { } ) } ) }"),
InternalError);
}
void garbageCode130() {
ASSERT_THROW(checkCode("enum { FOO = ( , ){ } { { } } { { FOO} = } ( ) } { { } } enumL\" ( enumL\" { { FOO } ( ) } { { } } ;"),
InternalError);
}
void garbageValueFlow() {