From 8494df74e66ad3b6aeb9bb677d7d6ba6933c235f Mon Sep 17 00:00:00 2001 From: Ettl Martin Date: Thu, 26 Apr 2012 13:16:46 +0200 Subject: [PATCH] #2540: added missing testcase. --- test/testmemleak.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/testmemleak.cpp b/test/testmemleak.cpp index afe6399c1..581a74d31 100644 --- a/test/testmemleak.cpp +++ b/test/testmemleak.cpp @@ -340,6 +340,7 @@ private: TEST_CASE(jmp); TEST_CASE(trac1949); + TEST_CASE(trac2540); // #2662: segfault because of endless recursion (call_func -> getAllocationType -> functionReturnType -> call_func ..) TEST_CASE(trac2662); @@ -3705,6 +3706,22 @@ private: ASSERT_EQUALS("[test.cpp:10]: (error) Memory leak: buff\n", errout.str()); } + void trac2540() { + check("void f()\n" + "{\n" + " char* str = strdup(\"abc def\");\n" + " char *name = strtok(str, \" \");\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:5]: (error) Memory leak: str\n", errout.str()); + + check("void f(char *cBuf)\n" + "{\n" + " char* str = strdup(*cBuf);\n" + " char *name = strtok(str, \" \");\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:5]: (error) Memory leak: str\n", errout.str()); + } + void trac2662() { // segfault because of endless recursion // call_func -> getAllocationType -> functionReturnType -> call_func ..