diff --git a/src/checkmemoryleak.cpp b/src/checkmemoryleak.cpp index 0611d5e17..6ddad4fc1 100644 --- a/src/checkmemoryleak.cpp +++ b/src/checkmemoryleak.cpp @@ -943,11 +943,25 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::liststrAt(0)); // exit.. - if (Token::Match(tok->previous(), "[{};] exit ( %any% ) ;")) + if (Token::Match(tok->previous(), "[{};] exit|_exit|_Exit ( %any% ) ;")) { addtoken("exit"); tok = tok->tokAt(3); } + else if (Token::simpleMatch(tok, "abort ( ) ;")) + { + addtoken("exit"); + tok = tok->tokAt(2); + } + else if (Token::Match(tok, "err|verr|errx|verrx (")) + { + addtoken("exit"); + while (tok->next() && tok->next()->str() != ";") + { + tok = tok->next(); + } + } + // Assignment.. if (varid) diff --git a/test/testmemleak.cpp b/test/testmemleak.cpp index 0125e2f10..226172251 100644 --- a/test/testmemleak.cpp +++ b/test/testmemleak.cpp @@ -384,6 +384,9 @@ private: // exit.. ASSERT_EQUALS(";;exit;", getcode("char *s; exit(0);", "s")); + ASSERT_EQUALS(";;exit;", getcode("char *s; _exit(0);", "s")); + ASSERT_EQUALS(";;exit;", getcode("char *s; abort();", "s")); + ASSERT_EQUALS(";;exit;", getcode("char *s; err(0);", "s")); ASSERT_EQUALS(";;if{exit;}", getcode("char *s; if (a) { exit(0); }", "s")); // open/close