#6744 segmentation fault (invalid code) in Tokenizer::simplifyPointerToStandardType. #6745 segmentation fault (invalid code) in Tokenizer::simplifyTypedef

This commit is contained in:
Alexander Mai 2015-06-02 21:20:41 +02:00
parent 454d4573b4
commit 6e1b5a0a53
2 changed files with 13 additions and 1 deletions

View File

@ -1194,7 +1194,7 @@ void Tokenizer::simplifyTypedef()
if (simplifyType) {
// can't simplify 'operator functionPtr ()' and 'functionPtr operator ... ()'
if (functionPtr && (tok2->previous()->str() == "operator" ||
tok2->next()->str() == "operator")) {
(tok2->next() && tok2->next()->str() == "operator"))) {
simplifyType = false;
tok2 = tok2->next();
continue;
@ -5213,6 +5213,8 @@ void Tokenizer::simplifyPointerToStandardType()
tok->next()->eraseTokens(tok->next(), tok->tokAt(5));
// Remove '&' prefix
tok = tok->previous();
if (!tok)
break;
tok->deleteNext();
}
}

View File

@ -105,6 +105,8 @@ private:
TEST_CASE(garbageCode64);
TEST_CASE(garbageCode65);
TEST_CASE(garbageCode66);
TEST_CASE(garbageCode67);
TEST_CASE(garbageCode68);
TEST_CASE(garbageValueFlow);
TEST_CASE(garbageSymbolDatabase);
@ -590,6 +592,14 @@ private:
ASSERT_THROW(checkCode("{ { } }; { { } }; { }; class bar : public virtual"), InternalError);
}
void garbageCode67() { // #6744
checkCode("&g[0]; { (g[0] 0) } =", "test.c");
}
void garbageCode68() { // #6745
checkCode("(int a[3]); typedef void (*fp) (void); fp");
}
void garbageValueFlow() {
// #6089