#6741 segmentation fault (invalid code) in Tokenizer::simplifyTypedef.

This commit is contained in:
Alexander Mai 2015-06-02 20:09:12 +02:00
parent 7fc9930b38
commit f348c8eebe
2 changed files with 10 additions and 5 deletions

View File

@ -1404,16 +1404,16 @@ void Tokenizer::simplifyTypedef()
tok2 = tok2->next(); tok2 = tok2->next();
// skip over name // skip over name
if (tok2->next()->str() != ")") { if (tok2 && tok2->next() && tok2->next()->str() != ")") {
if (tok2->next()->str() != "(") if (tok2->next()->str() != "(")
tok2 = tok2->next(); tok2 = tok2->next();
// check for function and skip over args // check for function and skip over args
if (tok2->next() && tok2->next()->str() == "(") if (tok2 && tok2->next() && tok2->next()->str() == "(")
tok2 = tok2->next()->link(); tok2 = tok2->next()->link();
// check for array // check for array
if (tok2->next() && tok2->next()->str() == "[") if (tok2 && tok2->next() && tok2->next()->str() == "[")
tok2 = tok2->next()->link(); tok2 = tok2->next()->link();
} else { } else {
// syntax error // syntax error

View File

@ -96,13 +96,14 @@ private:
TEST_CASE(garbageCode55); // #6724 TEST_CASE(garbageCode55); // #6724
TEST_CASE(garbageCode56); // #6713 TEST_CASE(garbageCode56); // #6713
TEST_CASE(garbageCode57); // #6733 TEST_CASE(garbageCode57); // #6733
//TEST_CASE(garbageCode58); // #6732 TEST_CASE(garbageCode58); // #6732
TEST_CASE(garbageCode59); // #6735 TEST_CASE(garbageCode59); // #6735
TEST_CASE(garbageCode60); // #6736 TEST_CASE(garbageCode60); // #6736
TEST_CASE(garbageCode61); TEST_CASE(garbageCode61);
TEST_CASE(garbageCode62); TEST_CASE(garbageCode62);
TEST_CASE(garbageCode63); TEST_CASE(garbageCode63);
TEST_CASE(garbageCode64); TEST_CASE(garbageCode64);
TEST_CASE(garbageCode65);
TEST_CASE(garbageValueFlow); TEST_CASE(garbageValueFlow);
TEST_CASE(garbageSymbolDatabase); TEST_CASE(garbageSymbolDatabase);
@ -553,7 +554,7 @@ private:
} }
void garbageCode58() { // #6732 void garbageCode58() { // #6732
ASSERT_THROW(checkCode("{ }> {= ~A()^{} }P { }"), InternalError); //ASSERT_THROW(checkCode("{ }> {= ~A()^{} }P { }"), InternalError);
} }
void garbageCode59() { // #6735 void garbageCode59() { // #6735
@ -580,6 +581,10 @@ private:
ASSERT_THROW(checkCode("{ } foo(void (*bar)(void))"), InternalError); ASSERT_THROW(checkCode("{ } foo(void (*bar)(void))"), InternalError);
} }
void garbageCode65() { // #6741
ASSERT_THROW(checkCode("{ } { } typedef int u_array[]; typedef u_array &u_array_ref; (u_array_ref arg) { } u_array_ref"), InternalError);
}
void garbageValueFlow() { void garbageValueFlow() {
// #6089 // #6089