#6739 segmentation fault (invalid code) in Tokenizer::simplifyTypedef. Fix segfault in the specified method

This commit is contained in:
Alexander Mai 2015-06-02 19:40:20 +02:00
parent be3690920a
commit a3bdd90df5
2 changed files with 9 additions and 4 deletions

View File

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

View File

@ -96,11 +96,12 @@ private:
TEST_CASE(garbageCode55); // #6724
TEST_CASE(garbageCode56); // #6713
TEST_CASE(garbageCode57); // #6733
TEST_CASE(garbageCode58); // #6732
//TEST_CASE(garbageCode58); // #6732
TEST_CASE(garbageCode59); // #6735
TEST_CASE(garbageCode60); // #6736
TEST_CASE(garbageCode61);
TEST_CASE(garbageCode62);
TEST_CASE(garbageCode63);
TEST_CASE(garbageValueFlow);
TEST_CASE(garbageSymbolDatabase);
@ -551,7 +552,7 @@ private:
}
void garbageCode58() { // #6732
//ASSERT_THROW(checkCode("{ }> {= ~A()^{} }P { }"), InternalError);
ASSERT_THROW(checkCode("{ }> {= ~A()^{} }P { }"), InternalError);
}
void garbageCode59() { // #6735
@ -570,6 +571,10 @@ private:
checkCode("(int arg2) { } { } typedef void (func_type) (int, int); typedef func_type&");
}
void garbageCode63() { // #6739
ASSERT_THROW(checkCode(" { } { } typedef int u_array[]; typedef u_array &u_array_ref; (u_array_ref arg) { } u_array_ref u_array_ref_gbl_obj0"), InternalError);
}
void garbageValueFlow() {
// #6089