Fix Cppcheck warning

This commit is contained in:
Daniel Marjamäki 2018-08-11 14:45:12 +02:00
parent 6008bbdfb4
commit f0c1d49abf
1 changed files with 4 additions and 1 deletions

View File

@ -111,7 +111,7 @@ void CheckStl::outOfBoundsError(const Token *tok, const ValueFlow::Value *contai
errmsg = "Accessing an item in container '$symbol'. " + ValueFlow::eitherTheConditionIsRedundant(containerSize->condition) + " or '$symbol' can be empty.";
else
errmsg = "Accessing an item in container '$symbol' that is empty.";
} else {
} else if (index) {
if (containerSize->condition || index->condition)
errmsg = "Possible access out of bounds";
else
@ -120,6 +120,9 @@ void CheckStl::outOfBoundsError(const Token *tok, const ValueFlow::Value *contai
errmsg += " of container '$symbol'; size=" +
MathLib::toString(containerSize->intvalue) + ", index=" +
MathLib::toString(index->intvalue);
} else {
// should not happen
return;
}
ErrorPath errorPath;