From 0ba3c15c52b6655509b07ec8d987f643d9fb509e Mon Sep 17 00:00:00 2001 From: Alexander Mai Date: Mon, 17 Nov 2014 23:05:15 +0100 Subject: [PATCH] Cure null pointer access within Scope::findFunction introduced by recent cs --- test/testsymboldatabase.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index e14c52f78..21ba08440 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -229,6 +229,7 @@ private: TEST_CASE(findFunction3); TEST_CASE(findFunction4); TEST_CASE(findFunction5); // #6230 + TEST_CASE(findFunction6); TEST_CASE(noexceptFunction1); TEST_CASE(noexceptFunction2); @@ -2352,6 +2353,14 @@ private: ASSERT_EQUALS(true, db && f && f->function() && f->function()->tokenDef->linenr() == 2); } + void findFunction6() { // avoid null pointer access + GET_SYMBOL_DB("void addtoken(Token** rettail, const Token *tok);\n" + "void CheckMemoryLeakInFunction::getcode(const Token *tok ) {\n" + " addtoken(&rettail, tok);\n" + "}"); + } + + #define FUNC(x) const Function *x = findFunctionByName(#x, &db->scopeList.front()); \ ASSERT_EQUALS(true, x != nullptr); \ if (x) ASSERT_EQUALS(true, x->isNoExcept);