#6909 segmentation fault (invalid code) in Tokenizer::simplifyEnum

This commit is contained in:
amai2012 2015-08-01 12:24:22 +02:00
parent acf050793e
commit b182edddda
2 changed files with 7 additions and 0 deletions

View File

@ -7530,6 +7530,8 @@ void Tokenizer::simplifyEnum()
for (; tok1 && tok1 != end; tok1 = tok1->next()) { for (; tok1 && tok1 != end; tok1 = tok1->next()) {
if (tok1->str() == "(") { if (tok1->str() == "(") {
tok1 = tok1->link(); tok1 = tok1->link();
if (!tok1)
syntaxError(nullptr); // #6909
continue; continue;
} }

View File

@ -151,6 +151,7 @@ private:
TEST_CASE(garbageCode109); TEST_CASE(garbageCode109);
TEST_CASE(garbageCode110); TEST_CASE(garbageCode110);
TEST_CASE(garbageCode111); TEST_CASE(garbageCode111);
TEST_CASE(garbageCode112);
TEST_CASE(garbageValueFlow); TEST_CASE(garbageValueFlow);
TEST_CASE(garbageSymbolDatabase); TEST_CASE(garbageSymbolDatabase);
@ -849,6 +850,10 @@ private:
ASSERT_THROW(checkCode("enum { FOO = 1( ,) } {{ FOO }} ;"), InternalError); ASSERT_THROW(checkCode("enum { FOO = 1( ,) } {{ FOO }} ;"), InternalError);
} }
void garbageCode112() { // #6909
ASSERT_THROW(checkCode("enum { FOO = ( , ) } {{ }}>> enum { FOO< = ( ) } { { } } ;"), InternalError);
}
void garbageValueFlow() { void garbageValueFlow() {