Fixed #4869 (segmentation fault in Tokenizer::simplifyStructDecl (invalid code))
This commit is contained in:
parent
bfc40ffe9f
commit
5a9975bbdd
|
@ -8587,6 +8587,8 @@ void Tokenizer::simplifyStructDecl()
|
||||||
continue;
|
continue;
|
||||||
skip.push(false);
|
skip.push(false);
|
||||||
tok = next->link();
|
tok = next->link();
|
||||||
|
if (!tok)
|
||||||
|
break; // see #4869 segmentation fault in Tokenizer::simplifyStructDecl (invalid code)
|
||||||
restart = next;
|
restart = next;
|
||||||
|
|
||||||
// check for named type
|
// check for named type
|
||||||
|
@ -8598,6 +8600,8 @@ void Tokenizer::simplifyStructDecl()
|
||||||
tok = tok->next();
|
tok = tok->next();
|
||||||
start->deleteThis();
|
start->deleteThis();
|
||||||
}
|
}
|
||||||
|
if (!tok)
|
||||||
|
break; // see #4869 segmentation fault in Tokenizer::simplifyStructDecl (invalid code)
|
||||||
tok->insertToken(type->str());
|
tok->insertToken(type->str());
|
||||||
if (start->str() != "class")
|
if (start->str() != "class")
|
||||||
tok->insertToken(start->str());
|
tok->insertToken(start->str());
|
||||||
|
|
|
@ -71,6 +71,7 @@ private:
|
||||||
TEST_CASE(syntax_case_default);
|
TEST_CASE(syntax_case_default);
|
||||||
TEST_CASE(garbageCode1);
|
TEST_CASE(garbageCode1);
|
||||||
TEST_CASE(garbageCode2); // #4300
|
TEST_CASE(garbageCode2); // #4300
|
||||||
|
TEST_CASE(garbageCode3); // #4869
|
||||||
|
|
||||||
TEST_CASE(simplifyFileAndLineMacro); // tokenize "return - __LINE__;"
|
TEST_CASE(simplifyFileAndLineMacro); // tokenize "return - __LINE__;"
|
||||||
|
|
||||||
|
@ -905,6 +906,10 @@ private:
|
||||||
tokenizeAndStringify("enum { D = 1 struct { } ; } s.b = D;");
|
tokenizeAndStringify("enum { D = 1 struct { } ; } s.b = D;");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void garbageCode3() { //#4849 (segmentation fault in Tokenizer::simplifyStructDecl (invalid code))
|
||||||
|
tokenizeAndStringify("enum { D = 2 s ; struct y { x } ; } { s.a = C ; s.b = D ; }");
|
||||||
|
}
|
||||||
|
|
||||||
void simplifyFileAndLineMacro() { // tokenize 'return - __LINE__' correctly
|
void simplifyFileAndLineMacro() { // tokenize 'return - __LINE__' correctly
|
||||||
ASSERT_EQUALS("return -1 ;", tokenizeAndStringify("return - __LINE__;"));
|
ASSERT_EQUALS("return -1 ;", tokenizeAndStringify("return - __LINE__;"));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue