diff --git a/lib/checkmemoryleak.cpp b/lib/checkmemoryleak.cpp index a8b8e2c42..52b7607d2 100644 --- a/lib/checkmemoryleak.cpp +++ b/lib/checkmemoryleak.cpp @@ -921,7 +921,7 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::listvarId() == varid || - tok2->str() == ":") + tok2->str() == ":" || tok2->str() == "{") { break; } diff --git a/test/testmemleak.cpp b/test/testmemleak.cpp index cba61fb40..36978ff79 100644 --- a/test/testmemleak.cpp +++ b/test/testmemleak.cpp @@ -520,6 +520,12 @@ private: // ticket #2336: calling member function with same name as a white_list function 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")); }