diff --git a/checkmemoryleak.cpp b/checkmemoryleak.cpp index 3c5f0e4be..7aba346d0 100644 --- a/checkmemoryleak.cpp +++ b/checkmemoryleak.cpp @@ -578,7 +578,8 @@ TOKEN *CheckMemoryLeakClass::getcode(const TOKEN *tok, std::list // Assignment.. if ( TOKEN::Match(tok,"[)=] %var1% [+;)]", varnames) || - TOKEN::Match(tok, "%var1% +=|-=", varnames) ) + TOKEN::Match(tok, "%var1% +=|-=", varnames) || + TOKEN::Match(tok, "+= %var1% ;", varnames) ) addtoken("use"); // Investigate function calls.. diff --git a/testmemleak.cpp b/testmemleak.cpp index 0e3ce947e..b1c00c2ff 100644 --- a/testmemleak.cpp +++ b/testmemleak.cpp @@ -1288,6 +1288,14 @@ private: "}\n" ); ASSERT_EQUALS( std::string(""), errout.str() ); + + check( "void foo()\n" + "{\n" + " char *a = new char[100];\n" + " list += a;\n" + "}\n" ); + + ASSERT_EQUALS( std::string(""), errout.str() ); }