Fixed #2112 (Crash scanning qtcreator sources)

This commit is contained in:
Daniel Marjamäki 2010-10-21 19:42:09 +02:00
parent 6a66d32871
commit eba827bc4b
2 changed files with 8 additions and 1 deletions

View File

@ -1282,7 +1282,7 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::list<const Toke
if (tok2->str() == "(")
f.push(tok2->previous());
else if (tok2->str() == ")")
else if (!f.empty() && tok2->str() == ")")
f.pop();
if (tok2->varId() == varid)

View File

@ -569,6 +569,13 @@ private:
// call memcpy in class function..
ASSERT_EQUALS(";;alloc;;", getcode("char *s; s = new char[10]; memcpy(s,a);", "s", true));
// #2112 - Segmentation fault in the getcode function
getcode("page *one = foo();\n"
"ASSERT(one, return 0)\n"
"const int two = rand();\n"
"return 0;\n"
"}", "one");
}