Cure null pointer access within Scope::findFunction introduced by recent cs

This commit is contained in:
Alexander Mai 2014-11-17 23:05:15 +01:00
parent c5e15950df
commit 0ba3c15c52
1 changed files with 9 additions and 0 deletions

View File

@ -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);