From 0be1892b9229c9bd366c2baad03e9c0fec6d6087 Mon Sep 17 00:00:00 2001 From: Alexander Mai Date: Sun, 16 Jun 2013 21:46:01 +0200 Subject: [PATCH] Fixed #4806 (Crash in Type::initBaseInfo() in clang testcode) --- lib/symboldatabase.cpp | 3 ++- test/testsymboldatabase.cpp | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 2be61124b..a50d29c73 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -1481,7 +1481,8 @@ const Token *Type::initBaseInfo(const Token *tok, const Token *tok1) // save pattern for base class name derivedFrom.push_back(base); } - tok2 = tok2->next(); + if (tok2) // see #4806 + tok2 = tok2->next(); } return tok2; diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index f3ffe2a81..321bcf3b2 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -192,6 +192,7 @@ private: TEST_CASE(symboldatabase31); TEST_CASE(symboldatabase33); // ticket #4682 (false negatives) TEST_CASE(symboldatabase34); // ticket #4694 (segmentation fault) + TEST_CASE(symboldatabase35); // ticket #4806 (segmentation fault) TEST_CASE(isImplicitlyVirtual); @@ -1506,6 +1507,12 @@ private: ASSERT_EQUALS("", errout.str()); } + void symboldatabase35() { // ticket #4806 and #4841 + check("class FragmentQueue : public CL_NS(util)::PriorityQueue >\n" + "{};"); + ASSERT_EQUALS("", errout.str()); + } + void isImplicitlyVirtual() { { GET_SYMBOL_DB("class Base {\n"