From 6d9463139d38dd4865fd292e91d3c2ea8bfb2af6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 25 Aug 2011 19:59:44 +0200 Subject: [PATCH] Fixed #3038 (False Positive - memory leak) --- lib/checkmemoryleak.cpp | 2 ++ test/testmemleak.cpp | 1 + 2 files changed, 3 insertions(+) diff --git a/lib/checkmemoryleak.cpp b/lib/checkmemoryleak.cpp index f1736b9e8..a491afa3f 100644 --- a/lib/checkmemoryleak.cpp +++ b/lib/checkmemoryleak.cpp @@ -848,6 +848,8 @@ const char * CheckMemoryLeakInFunction::call_func(const Token *tok, std::list 0 && Token::Match(tok, "[(,] %varid% . %var% [,)]", varid)) + return "use"; } } return NULL; diff --git a/test/testmemleak.cpp b/test/testmemleak.cpp index 408fa60c9..5dcc63287 100644 --- a/test/testmemleak.cpp +++ b/test/testmemleak.cpp @@ -487,6 +487,7 @@ private: ASSERT_EQUALS(";;use;;", getcode("char *s; x = {1,s};", "s")); ASSERT_EQUALS(";{};;alloc;;use;", getcode("struct Foo { }; Foo *p; p = malloc(10); const Foo *q; q = p;", "p")); ASSERT_EQUALS(";;alloc;use;", getcode("Fred *fred; p.setFred(fred = new Fred);", "fred")); + ASSERT_EQUALS(";;use;", getcode("struct AB *ab; f(ab->a);", "ab")); // non-use.. ASSERT_EQUALS(";;", getcode("char *s; s = s + 1;", "s"));