negativeContainerIndex: avoid crash when AST is wrong

This commit is contained in:
Daniel Marjamäki 2017-08-22 12:30:43 +02:00
parent 2679b576c2
commit b7f9e7ed1d
1 changed files with 1 additions and 1 deletions

View File

@ -446,7 +446,7 @@ void CheckStl::negativeIndex()
for (std::size_t ii = 0; ii < functions; ++ii) {
const Scope * scope = symbolDatabase->functionScopes[ii];
for (const Token* tok = scope->classStart->next(); tok != scope->classEnd; tok = tok->next()) {
if (!Token::Match(tok, "%var% ["))
if (!Token::Match(tok, "%var% [") || WRONG_DATA(!tok->next()->astOperand2(), tok))
continue;
const Variable * const var = tok->variable();
if (!var || tok == var->nameToken())