diff --git a/src/checkmemoryleak.cpp b/src/checkmemoryleak.cpp index b621d7427..7fc53f483 100644 --- a/src/checkmemoryleak.cpp +++ b/src/checkmemoryleak.cpp @@ -916,7 +916,8 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::liststr() == "for") || (tok->str() == "while")) { - if (Token::simpleMatch(tok, "while ( true )")) + if (Token::simpleMatch(tok, "while ( true )") || + Token::simpleMatch(tok, "for ( ; ; )")) { addtoken("while1"); tok = tok->next()->link(); diff --git a/test/testmemleak.cpp b/test/testmemleak.cpp index c4390bfea..38db4edea 100644 --- a/test/testmemleak.cpp +++ b/test/testmemleak.cpp @@ -361,6 +361,7 @@ private: ASSERT_EQUALS(";;loop{alloc;}", getcode("char *s; for (a;b;c) { s=malloc(10); }", "s")); ASSERT_EQUALS(";;do{}loop;", getcode("char *s; do { } while (a);", "s")); ASSERT_EQUALS(";;while1{}", getcode("char *s; while(true) { }", "s")); + ASSERT_EQUALS(";;while1{}", getcode("char *s; for(;;) { }", "s")); // asprintf.. ASSERT_EQUALS(";;alloc;", getcode("char *s; asprintf(&s, \"xyz\");", "s"));