#6757 segmentation fault (invalid code) in Tokenizer::simplifyTypedef. Fix crash

This commit is contained in:
amai 2015-06-04 19:00:35 +02:00
parent 5f4902c613
commit 5fd9dd04fa
2 changed files with 7 additions and 1 deletions

View File

@ -541,7 +541,8 @@ Token *Tokenizer::processFunc(Token *tok2, bool inOperator) const
return nullptr;
if (tok2->str() == "(" &&
tok2->link()->next()->str() == "(") {
tok2->link()->next() &&
tok2->link()->next()->str() == "(") {
tok2 = tok2->link();
if (tok2->next()->str() == "(")

View File

@ -117,6 +117,7 @@ private:
TEST_CASE(garbageCode76);
TEST_CASE(garbageCode77);
TEST_CASE(garbageCode78);
TEST_CASE(garbageCode79);
TEST_CASE(garbageValueFlow);
TEST_CASE(garbageSymbolDatabase);
@ -650,6 +651,10 @@ private:
checkCode("( ) { [ ] } ( ) { } const_array_of_int ( ) { } typedef int A [ ] [ ] ; A a = { { } { } }");
}
void garbageCode79() { // #6757
ASSERT_THROW(checkCode("{ } { } typedef void ( func_type ) ( ) ; func_type & ( )"), InternalError);
}
void garbageValueFlow() {
// #6089
const char* code = "{} int foo(struct, x1, struct x2, x3, int, x5, x6, x7)\n"