Another fix for 10728: Crash in CheckStl::checkDereferenceInvalidIterator2() (#3735)
* Another fix for 10728: Crash in CheckStl::checkDereferenceInvalidIterator2() * Format
This commit is contained in:
parent
0737cc4d8c
commit
6c2b1f093d
|
@ -2332,6 +2332,9 @@ void CheckStl::checkDereferenceInvalidIterator2()
|
|||
}
|
||||
if (cValue) {
|
||||
const ValueFlow::Value& lValue = getLifetimeIteratorValue(tok, cValue->path);
|
||||
assert(cValue->isInconclusive() || value.isInconclusive() || lValue.isLifetimeValue());
|
||||
if (!lValue.isLifetimeValue())
|
||||
continue;
|
||||
if (emptyAdvance)
|
||||
outOfBoundsError(emptyAdvance,
|
||||
lValue.tokvalue->expressionString(),
|
||||
|
|
|
@ -705,6 +705,18 @@ private:
|
|||
true);
|
||||
ASSERT_EQUALS("test.cpp:4:error:Out of bounds access in expression 'd+c.length()' because 'buf' is empty.\n",
|
||||
errout.str());
|
||||
|
||||
check("template<class Iterator>\n"
|
||||
"void b(Iterator d) {\n"
|
||||
" std::string c = \"a\";\n"
|
||||
" sort(d, d + c.length());\n"
|
||||
"}\n"
|
||||
"void f() {\n"
|
||||
" std::string buf;\n"
|
||||
" b(buf.begin());\n"
|
||||
"}\n",
|
||||
true);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void outOfBoundsSymbolic()
|
||||
|
|
Loading…
Reference in New Issue