diff --git a/src/checkmemoryleak.cpp b/src/checkmemoryleak.cpp index f92e94dee..bf9c67f13 100644 --- a/src/checkmemoryleak.cpp +++ b/src/checkmemoryleak.cpp @@ -627,8 +627,9 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::liststr() == ";") addtoken(";"); - if (Token::Match(tok->previous(), "[(;{}] %varid% =", varid) || - Token::Match(tok, "asprintf ( & %varid% ,", varid)) + if (varid && + (Token::Match(tok->previous(), "[(;{}] %varid% =", varid) || + Token::Match(tok, "asprintf ( & %varid% ,", varid))) { AllocType alloc;