From 065e2e277e60051f8d5449b8a46edc657a702aa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 17 Jan 2011 19:00:21 +0100 Subject: [PATCH] Fixed #2473 (False positive: Memory leak when there is local struct) --- lib/checkmemoryleak.cpp | 2 +- test/testmemleak.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) 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")); }