Fix 10716: Crash in CheckStl::checkDereferenceInvalidIterator2 (#3709)
* Fix 10716: Crash in CheckStl::checkDereferenceInvalidIterator2 * Format
This commit is contained in:
parent
781a145680
commit
2b6a89e30e
|
@ -2329,7 +2329,7 @@ void CheckStl::checkDereferenceInvalidIterator2()
|
|||
inconclusive = true;
|
||||
}
|
||||
if (cValue) {
|
||||
const ValueFlow::Value& lValue = getLifetimeObjValue(tok, true);
|
||||
const ValueFlow::Value& lValue = getLifetimeIteratorValue(tok);
|
||||
if (emptyAdvance)
|
||||
outOfBoundsError(emptyAdvance,
|
||||
lValue.tokvalue->expressionString(),
|
||||
|
|
|
@ -4243,6 +4243,20 @@ private:
|
|||
" return *(v.begin() + v.size() - 1);\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// #10716
|
||||
check("struct a;\n"
|
||||
"class b {\n"
|
||||
" void c(std::map<std::string, a *> &);\n"
|
||||
" std::string d;\n"
|
||||
" std::map<std::string, std::set<std::string>> e;\n"
|
||||
"};\n"
|
||||
"void b::c(std::map<std::string, a *> &) {\n"
|
||||
" e.clear();\n"
|
||||
" auto f = *e[d].begin();\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:9]: (error) Out of bounds access in expression 'e[d].begin()' because 'e[d]' is empty.\n",
|
||||
errout.str());
|
||||
}
|
||||
|
||||
void dereferenceInvalidIterator2() {
|
||||
|
|
Loading…
Reference in New Issue