* Fix leakNoVarFunctionCall FP * Partial fix for #9157 False negative: stlOutOfBounds, cast
This commit is contained in:
parent
858585ceb1
commit
586c29c772
|
@ -177,7 +177,7 @@ void CheckStl::outOfBounds()
|
|||
return false;
|
||||
const Token* sizeTok = v.tokvalue;
|
||||
if (sizeTok && sizeTok->isCast())
|
||||
sizeTok = sizeTok->astOperand1();
|
||||
sizeTok = sizeTok->astOperand2() ? sizeTok->astOperand2() : sizeTok->astOperand1();
|
||||
const Token* containerTok = getContainerFromSize(container, sizeTok);
|
||||
if (!containerTok)
|
||||
return false;
|
||||
|
|
|
@ -690,10 +690,16 @@ private:
|
|||
" if (i <= (int)v.size()) {\n"
|
||||
" if (v[i]) {}\n"
|
||||
" }\n"
|
||||
" if (i <= static_cast<int>(v.size())) {\n"
|
||||
" if (v[i]) {}\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("test.cpp:3:warning:Either the condition 'i<=(int)v.size()' is redundant or 'i' can have the value v.size(). Expression 'v[i]' cause access out of bounds.\n"
|
||||
"test.cpp:2:note:condition 'i<=(int)v.size()'\n"
|
||||
"test.cpp:3:note:Access out of bounds\n",
|
||||
"test.cpp:3:note:Access out of bounds\n"
|
||||
"test.cpp:6:warning:Either the condition 'i<=static_cast<int>(v.size())' is redundant or 'i' can have the value v.size(). Expression 'v[i]' cause access out of bounds.\n"
|
||||
"test.cpp:5:note:condition 'i<=static_cast<int>(v.size())'\n"
|
||||
"test.cpp:6:note:Access out of bounds\n",
|
||||
errout.str());
|
||||
|
||||
check("template<class Iterator>\n"
|
||||
|
|
Loading…
Reference in New Issue