From 6bb85703f61befdf9e37e63d9f99db28de05ea5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 24 Jul 2009 09:05:40 +0200 Subject: [PATCH] memory leaks: fixed false positive for struct members - better handling of if/else --- src/checkmemoryleak.cpp | 2 +- test/testmemleak.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/checkmemoryleak.cpp b/src/checkmemoryleak.cpp index 55912ad08..a6bfc374e 100644 --- a/src/checkmemoryleak.cpp +++ b/src/checkmemoryleak.cpp @@ -2029,7 +2029,7 @@ void CheckMemoryLeakStructMember::check() } // Deallocating the struct.. - else if (Token::Match(tok3, "free|kfree ( %varid% )", structid)) + else if (indentlevel2 == 0 && Token::Match(tok3, "free|kfree ( %varid% )", structid)) { memoryLeak(tok3, (vartok->str() + "." + tok2->strAt(2)).c_str(), Malloc, false); break; diff --git a/test/testmemleak.cpp b/test/testmemleak.cpp index 04d996805..24b8dee38 100644 --- a/test/testmemleak.cpp +++ b/test/testmemleak.cpp @@ -2995,7 +2995,7 @@ private: " free(abc->a);\n" " free(abc);\n" "}\n"); - TODO_ASSERT_EQUALS("", errout.str()); + ASSERT_EQUALS("", errout.str()); } };