#6385 crash in Variable::getFlag(). Catch token without variable in fix for #6095.

This commit is contained in:
Alexander Mai 2014-12-31 18:19:10 +01:00
parent 5c2a2a5c22
commit d2caf89706
2 changed files with 14 additions and 1 deletions

View File

@ -426,7 +426,8 @@ void CheckCondition::oppositeInnerCondition()
}
if (Token::Match(tok->previous(), "++|--|& %var%"))
break;
if (Token::Match(tok, "%var% . %var% (") &&
if (tok->variable() &&
Token::Match(tok, "%var% . %var% (") &&
!tok->variable()->isConst() &&
!(tok->tokAt(2)->function() && tok->tokAt(2)->function()->isConst))
break;

View File

@ -1091,6 +1091,18 @@ private:
" }\n"
"}");
ASSERT_EQUALS("", errout.str());
// #6385 "crash in Variable::getFlag()"
check("class TranslationHandler {\n"
"QTranslator *mTranslator;\n"
"void SetLanguage() {\n"
" if (mTranslator) {\n"
" qApp->removeTranslator(mTranslator);\n"
" }\n"
" }\n"
"};");
ASSERT_EQUALS("", errout.str()); // just don't crash...
}
// #5731 - fp when undeclared variable is used