From 73c028bdb7d425ce88b6ff0f1234ef8036206cdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 23 Jul 2009 22:29:31 +0200 Subject: [PATCH] memory leaks: added a todo test case for struct members when using if-else --- test/testmemleak.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/testmemleak.cpp b/test/testmemleak.cpp index 48ef0079a..04d996805 100644 --- a/test/testmemleak.cpp +++ b/test/testmemleak.cpp @@ -2839,6 +2839,9 @@ private: // Deallocating in a function TEST_CASE(function); + + // Handle if-else + TEST_CASE(ifelse); } void err() @@ -2974,6 +2977,26 @@ private: "}\n"); ASSERT_EQUALS("", errout.str()); } + + void ifelse() + { + check("static void foo()\n" + "{\n" + " struct ABC *abc = malloc(sizeof(struct ABC));\n" + " if (x)" + " {\n" + " abc->a = malloc(10);\n" + " }\n" + " else\n" + " {\n" + " free(abc);\n" + " return;\n" + " }\n" + " free(abc->a);\n" + " free(abc);\n" + "}\n"); + TODO_ASSERT_EQUALS("", errout.str()); + } };