Skip to content

Commit

Permalink
Check offset
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Jan 29, 2024
1 parent 99e540d commit 9b2fdc7
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/checkstl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3149,14 +3149,15 @@ void CheckStl::eraseEndIterator()
if (args.size() != 1) // empty range is ok
continue;

if (const ValueFlow::Value* itValue = args[0]->getKnownValue(ValueFlow::Value::ValueType::ITERATOR_END)) {
if (itValue->intvalue == 0)
if (const ValueFlow::Value* endVal = args[0]->getKnownValue(ValueFlow::Value::ValueType::ITERATOR_END)) {
if (endVal->intvalue == 0)
eraseEndIteratorError(tok->tokAt(2), args[0]);
}
else if (args[0]->getKnownValue(ValueFlow::Value::ValueType::ITERATOR_START)) {
if (const ValueFlow::Value* sizeValue = tok->getKnownValue(ValueFlow::Value::ValueType::CONTAINER_SIZE))
if (sizeValue->intvalue == 0)
eraseEndIteratorError(tok->tokAt(2), args[0]);
else if (const ValueFlow::Value* startVal = args[0]->getKnownValue(ValueFlow::Value::ValueType::ITERATOR_START)) {
if (startVal->intvalue == 0)
if (const ValueFlow::Value* sizeVal = tok->getKnownValue(ValueFlow::Value::ValueType::CONTAINER_SIZE))
if (sizeVal->intvalue == 0)
eraseEndIteratorError(tok->tokAt(2), args[0]);
}
}
}
Expand Down

0 comments on commit 9b2fdc7

Please sign in to comment.