Fixed #3963 (segmentation fault of cppcheck (invalid typedef code))
This commit is contained in:
parent
9e916eec66
commit
735c0f5f6b
|
@ -1402,6 +1402,11 @@ void Tokenizer::simplifyTypedef()
|
|||
Token::createMutualLinks(tok2, tok3);
|
||||
}
|
||||
|
||||
if (!tok2->next()) {
|
||||
syntaxError(tok2);
|
||||
return; // can't recover so quit
|
||||
}
|
||||
|
||||
tok2 = copyTokens(tok2, arrayStart, arrayEnd);
|
||||
tok2 = tok2->next();
|
||||
|
||||
|
|
|
@ -288,6 +288,7 @@ private:
|
|||
TEST_CASE(simplifyTypedef104); // ticket #3070
|
||||
TEST_CASE(simplifyTypedef105); // ticket #3616
|
||||
TEST_CASE(simplifyTypedef106); // ticket #3619
|
||||
TEST_CASE(simplifyTypedef107); // ticket #3963 - bad code => segmentation fault
|
||||
|
||||
TEST_CASE(simplifyTypedefFunction1);
|
||||
TEST_CASE(simplifyTypedefFunction2); // ticket #1685
|
||||
|
@ -5715,6 +5716,12 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void simplifyTypedef107() { // ticket #3963 (bad code => segmentation fault)
|
||||
const char code[] = "typedef int x[]; int main() { return x }";
|
||||
tok(code);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void simplifyTypedefFunction1() {
|
||||
{
|
||||
const char code[] = "typedef void (*my_func)();\n"
|
||||
|
|
Loading…
Reference in New Issue