diff --git a/lib/checkleakautovar.cpp b/lib/checkleakautovar.cpp index d591105f9..bc9b8f0b9 100644 --- a/lib/checkleakautovar.cpp +++ b/lib/checkleakautovar.cpp @@ -248,8 +248,8 @@ void CheckLeakAutoVar::checkScope(const Token * const startToken, continue; // allocation? - if (Token::Match(tok->tokAt(2), "%type% (")) { - int i = _settings->library.alloc(tok->tokAt(2)); + if (tok->next()->astOperand2() && Token::Match(tok->next()->astOperand2()->previous(), "%type% (")) { + int i = _settings->library.alloc(tok->next()->astOperand2()->previous()); if (i > 0) { alloctype[tok->varId()].type = i; alloctype[tok->varId()].status = VarInfo::ALLOC;