#6738 Avoid segfault on garbage code in Tokenizer::simplifyTypedef()
This commit is contained in:
parent
7895f1c2bb
commit
be3690920a
|
@ -878,13 +878,13 @@ void Tokenizer::simplifyTypedef()
|
|||
// typedef ... (( ... type )( ... ));
|
||||
// typedef ... ( * ( ... type )( ... ));
|
||||
else if (tokOffset->str() == "(" && (
|
||||
(Token::Match(tokOffset->link()->previous(), "%type% ) (") &&
|
||||
(tokOffset->link() && Token::Match(tokOffset->link()->previous(), "%type% ) (") &&
|
||||
Token::Match(tokOffset->link()->next()->link(), ") const|volatile|;")) ||
|
||||
(Token::simpleMatch(tokOffset, "( (") &&
|
||||
Token::Match(tokOffset->next()->link()->previous(), "%type% ) (") &&
|
||||
tokOffset->next() && Token::Match(tokOffset->next()->link()->previous(), "%type% ) (") &&
|
||||
Token::Match(tokOffset->next()->link()->next()->link(), ") const|volatile| ) ;|,")) ||
|
||||
(Token::simpleMatch(tokOffset, "( * (") &&
|
||||
Token::Match(tokOffset->linkAt(2)->previous(), "%type% ) (") &&
|
||||
tokOffset->linkAt(2) && Token::Match(tokOffset->linkAt(2)->previous(), "%type% ) (") &&
|
||||
Token::Match(tokOffset->linkAt(2)->next()->link(), ") const|volatile| ) ;|,")))) {
|
||||
if (tokOffset->next()->str() == "(")
|
||||
tokOffset = tokOffset->next();
|
||||
|
|
|
@ -100,6 +100,7 @@ private:
|
|||
TEST_CASE(garbageCode59); // #6735
|
||||
TEST_CASE(garbageCode60); // #6736
|
||||
TEST_CASE(garbageCode61);
|
||||
TEST_CASE(garbageCode62);
|
||||
|
||||
TEST_CASE(garbageValueFlow);
|
||||
TEST_CASE(garbageSymbolDatabase);
|
||||
|
@ -565,6 +566,10 @@ private:
|
|||
ASSERT_THROW(checkCode("{ (const U&) }; { }; { }; struct U : virtual public"), InternalError);
|
||||
}
|
||||
|
||||
void garbageCode62() { // #6738
|
||||
checkCode("(int arg2) { } { } typedef void (func_type) (int, int); typedef func_type&");
|
||||
}
|
||||
|
||||
|
||||
void garbageValueFlow() {
|
||||
// #6089
|
||||
|
|
Loading…
Reference in New Issue