Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

commit 4050d56169f9c5db54654fa0858852dffd678669 1 parent d5d6d7f
@amai2012 amai2012 authored
Showing with 9 additions and 0 deletions.
  1. +4 −0 lib/tokenize.cpp
  2. +5 −0 test/testgarbage.cpp
View
4 lib/tokenize.cpp
@@ -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
5 test/testgarbage.cpp
@@ -92,6 +92,7 @@ class TestGarbage : public TestFixture {
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 @@ class TestGarbage : public TestFixture {
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"
Please sign in to comment.
Something went wrong with that request. Please try again.