Fixed #2473 (False positive: Memory leak when there is local struct)

This commit is contained in:
Daniel Marjamäki 2011-01-17 19:00:21 +01:00
parent 959e10cee5
commit 065e2e277e
2 changed files with 7 additions and 1 deletions

View File

@ -921,7 +921,7 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::list<const Toke
} }
if (tok2->varId() == varid || if (tok2->varId() == varid ||
tok2->str() == ":") tok2->str() == ":" || tok2->str() == "{")
{ {
break; break;
} }

View File

@ -520,6 +520,12 @@ private:
// ticket #2336: calling member function with same name as a white_list function // ticket #2336: calling member function with same name as a white_list function
ASSERT_EQUALS(";;use;", getcode("char *s; foo.write(s);", "s")); ASSERT_EQUALS(";;use;", getcode("char *s; foo.write(s);", "s"));
// #2473 - inner struct
ASSERT_EQUALS(";;alloc;{;;};dealloc;",
getcode("char *s = new char[10];\n"
"struct ab { int a, b; };\n"
"delete [] s;\n", "s"));
} }