Fix CID 1378763

Defensive check recovered from earlier version of this code
This commit is contained in:
Dmitry-Me 2017-09-05 00:17:51 +03:00
parent 7e823e6d8e
commit d7b91a9e92
1 changed files with 4 additions and 3 deletions

View File

@ -1668,10 +1668,11 @@ void CheckOther::zerodivError(const Token *tok, const ValueFlow::Value *value)
const ErrorPath errorPath = getErrorPath(tok, value, "Division by zero");
std::ostringstream errmsg;
if (value->condition)
if (value->condition) {
unsigned int line = tok ? tok->linenr() : 0;
errmsg << ValueFlow::eitherTheConditionIsRedundant(value->condition)
<< " or there is division by zero at line " << tok->linenr() << ".";
else
<< " or there is division by zero at line " << line << ".";
} else
errmsg << "Division by zero.";
reportError(errorPath,