diff --git a/testmemleak.cpp b/testmemleak.cpp index 405e5c554..86039e528 100644 --- a/testmemleak.cpp +++ b/testmemleak.cpp @@ -76,6 +76,8 @@ private: TEST_CASE( switch1 ); TEST_CASE( switch2 ); + TEST_CASE( ret ); + TEST_CASE( mismatch1 ); TEST_CASE( func1 ); @@ -410,6 +412,20 @@ private: + void ret() + { + check( "char *f( char **str )\n" + "{\n" + " char *ret = malloc( 10 );\n" + " return *str = ret;\n" + "}\n" ); + + ASSERT_EQUALS( std::string(""), errout.str() ); + } + + + + void mismatch1() diff --git a/tokenize.cpp b/tokenize.cpp index 123676636..80dd94b5a 100644 --- a/tokenize.cpp +++ b/tokenize.cpp @@ -888,9 +888,9 @@ void SimplifyTokenList() continue; TOKEN *type0 = tok->next; - if (!type0) - break; - if (strcmp(type0->str, "else") == 0) + if (!Match(type0, "%type%")) + continue; + if (Match(type0, "else") || Match(type0, "return")) continue; TOKEN *tok2 = NULL;