#4245: Segmentation fault (invalid code); Applied patch from amai.
This commit is contained in:
parent
f74c30e116
commit
0879bb5825
|
@ -5131,9 +5131,11 @@ void Tokenizer::simplifyVarDecl(bool only_k_r_fpar)
|
|||
|
||||
else if (strchr(";,", tok2->str()[0])) {
|
||||
// "type var =" => "type var; var ="
|
||||
Token *VarTok = type0->tokAt((int)typelen);
|
||||
const Token *VarTok = type0->tokAt((int)typelen);
|
||||
while (Token::Match(VarTok, "*|&|const"))
|
||||
VarTok = VarTok->next();
|
||||
if (!VarTok)
|
||||
break; // ticket 4245 - invalid code probably
|
||||
list.insertTokens(eq, VarTok, 2);
|
||||
eq->str(";");
|
||||
|
||||
|
|
|
@ -58,6 +58,7 @@ private:
|
|||
TEST_CASE(tokenize23); // tokenize "return - __LINE__;"
|
||||
TEST_CASE(tokenize24); // #4195 (segmentation fault)
|
||||
TEST_CASE(tokenize25); // #4239 (segmentation fault)
|
||||
TEST_CASE(tokenize26); // #4245 (segmentation fault)
|
||||
|
||||
// don't freak out when the syntax is wrong
|
||||
TEST_CASE(wrong_syntax1);
|
||||
|
@ -651,6 +652,11 @@ private:
|
|||
void tokenize25() {
|
||||
tokenizeAndStringify("f ( struct { int typedef T x ; } ) { }");
|
||||
}
|
||||
|
||||
// #4245 - segfault
|
||||
void tokenize26() {
|
||||
tokenizeAndStringify("class x { protected : template < int y = } ;");
|
||||
}
|
||||
|
||||
void wrong_syntax1() {
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue