check if AST is not null before accessing it

This commit is contained in:
Harald Scheidl 2016-10-09 16:50:59 +02:00 committed by Daniel Marjamäki
parent 1aeb260a63
commit 04421f5601
1 changed files with 1 additions and 1 deletions

View File

@ -991,7 +991,7 @@ void CheckCondition::alwaysTrueFalse()
// Don't warn in assertions. Condition is often 'always true' by intention.
// If platform,defines,etc cause 'always false' then that is not dangerous neither.
const std::string &str = tok->astParent()->previous()->str();
const std::string str = tok->astParent() && tok->astParent()->previous() ? tok->astParent()->previous()->str() : "";
if (str.find("assert")!=std::string::npos || str.find("ASSERT")!=std::string::npos)
continue;