#6722 segmentation fault (invalid code) in Tokenizer::simplifyTypedef

This commit is contained in:
Alexander Mai 2015-05-29 21:44:00 +02:00
parent d5d6d7fbb8
commit 4050d56169
2 changed files with 9 additions and 0 deletions

View File

@ -903,6 +903,10 @@ void Tokenizer::simplifyTypedef()
typeName = tokOffset->previous();
argStart = tokOffset->next();
argEnd = tokOffset->next()->link();
if (!argEnd) {
syntaxError(argStart);
return;
}
tok = argEnd->next();
Token *spec = tok;
if (Token::Match(spec, "const|volatile")) {

View File

@ -92,6 +92,7 @@ private:
TEST_CASE(garbageCode51); // #6719
TEST_CASE(garbageCode52); // #6720
TEST_CASE(garbageCode53); // #6721
TEST_CASE(garbageCode54); // #6722
TEST_CASE(garbageValueFlow);
TEST_CASE(garbageSymbolDatabase);
@ -525,6 +526,10 @@ private:
checkCode("{ { } }; void foo (struct int i) { x->b[i] = = }");
}
void garbageCode54() { // #6722
ASSERT_THROW(checkCode("{ typedef long ((pf) p) (); }"), InternalError);
}
void garbageValueFlow() {
// #6089
const char* code = "{} int foo(struct, x1, struct x2, x3, int, x5, x6, x7)\n"