diff --git a/lib/checkmemoryleak.cpp b/lib/checkmemoryleak.cpp index 1ef95c998..22051a671 100644 --- a/lib/checkmemoryleak.cpp +++ b/lib/checkmemoryleak.cpp @@ -715,7 +715,9 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::listnext(), "%name% .")) + if (Token::Match(tok2, "[{};] :: %name%")) + tok2 = tok2->next(); + while (Token::Match(tok2->next(), "%name% ::|. %name%")) tok2 = tok2->tokAt(2); if (Token::Match(tok2->next(), "%name% (")) ; diff --git a/test/testmemleak.cpp b/test/testmemleak.cpp index bb8c07104..68b370545 100644 --- a/test/testmemleak.cpp +++ b/test/testmemleak.cpp @@ -560,6 +560,8 @@ private: ASSERT_EQUALS(";;exit;", getcode("char *s; abort();", "s")); ASSERT_EQUALS(";;callfunc;", getcode("char *s; err(0);", "s")); // not in std.cfg ASSERT_EQUALS(";;if{exit;}", getcode("char *s; if (a) { exit(0); }", "s")); + ASSERT_EQUALS(";;if{exit;}", getcode("char *s; if (a) { ::exit(0); }", "s")); + ASSERT_EQUALS(";;if{exit;}", getcode("char *s; if (a) { std::exit(0); }", "s")); // list_for_each ASSERT_EQUALS(";;exit;{}}", getcode("void f() { char *s; list_for_each(x,y,s) { } }", "s"));