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()); + } };