From f87056fca3ca1e0cbfd536cba754bacaa1d0c82f Mon Sep 17 00:00:00 2001 From: Robert Reif Date: Fri, 4 Feb 2011 20:19:49 +0100 Subject: [PATCH] Fixed #2539 (segmentation fault of cppcheck) --- lib/symboldatabase.cpp | 4 +++- test/testclass.cpp | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index a9634b2d1..af0dd6818 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -581,7 +581,9 @@ bool SymbolDatabase::isFunction(const Token *tok, const Token **funcStart, const } // regular function? - else if (Token::Match(tok, "%var% (") && Token::Match(tok->next()->link(), ") const| ;|{|=|:")) + else if (Token::Match(tok, "%var% (") && + (Token::Match(tok->next()->link(), ") const| ;|{|=") || + Token::Match(tok->next()->link(), ") : %var% ("))) { *funcStart = tok; *argStart = tok->next(); diff --git a/test/testclass.cpp b/test/testclass.cpp index ffeac3df6..0fd7f6fcd 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -189,6 +189,7 @@ private: TEST_CASE(symboldatabase8); // ticket #2252 TEST_CASE(symboldatabase9); // ticket #2525 TEST_CASE(symboldatabase10); // ticket #2537 + TEST_CASE(symboldatabase11); // ticket #2539 } // Check the operator Equal @@ -5505,6 +5506,17 @@ private: ASSERT_EQUALS("", errout.str()); } + void symboldatabase11() + { + // ticket #2539 - segmentation fault + checkConst("int g ();\n" + "struct S {\n" + " int i : (false ? g () : 1);\n" + "};\n"); + + ASSERT_EQUALS("", errout.str()); + } + }; REGISTER_TEST(TestClass)