| 3356 | } |
| 3357 | |
| 3358 | void CheckStlImpl::eraseIteratorOutOfBounds() |
| 3359 | { |
| 3360 | logChecker("CheckStl::eraseIteratorOutOfBounds"); |
| 3361 | for (const Scope *function : mTokenizer->getSymbolDatabase()->functionScopes) { |
| 3362 | for (const Token *tok = function->bodyStart; tok != function->bodyEnd; tok = tok->next()) { |
| 3363 | |
| 3364 | if (!tok->valueType()) |
| 3365 | continue; |
| 3366 | const Library::Container* container = tok->valueType()->container; |
| 3367 | if (!container || !astIsLHS(tok) || !Token::simpleMatch(tok->astParent(), ".")) |
| 3368 | continue; |
| 3369 | const Token* const ftok = tok->astParent()->astOperand2(); |
| 3370 | const Library::Container::Action action = container->getAction(ftok->str()); |
| 3371 | if (action != Library::Container::Action::ERASE) |
| 3372 | continue; |
| 3373 | const std::vector<const Token*> args = getArguments(ftok); |
| 3374 | if (args.size() != 1) // TODO: check range overload |
| 3375 | continue; |
| 3376 | |
| 3377 | const ValueFlow::Value* sizeVal = tok->getKnownValue(ValueFlow::Value::ValueType::CONTAINER_SIZE); |
| 3378 | if (const ValueFlow::Value* errVal = getOOBIterValue(args[0], sizeVal)) |
| 3379 | eraseIteratorOutOfBoundsError(ftok, args[0], errVal); |
| 3380 | } |
| 3381 | } |
| 3382 | } |
| 3383 | |
| 3384 | static bool isMutex(const Variable* var) |
| 3385 | { |
no test coverage detected