Fixed #10367 (False positive; pointer out of bounds argv-1)
This commit is contained in:
parent
2d3b8d7003
commit
a9a093e7cc
|
@ -486,6 +486,9 @@ void CheckBufferOverrun::pointerArithmetic()
|
|||
if (const ValueFlow::Value *neg = indexToken->getValueLE(-1, mSettings))
|
||||
pointerArithmeticError(tok, indexToken, neg);
|
||||
} else if (tok->str() == "-") {
|
||||
if (arrayToken->variable() && arrayToken->variable()->isArgument())
|
||||
continue;
|
||||
|
||||
const Token *array = arrayToken;
|
||||
while (Token::Match(array, ".|::"))
|
||||
array = array->astOperand2();
|
||||
|
|
|
@ -3176,6 +3176,11 @@ private:
|
|||
" dostuff(x-i);\n"
|
||||
"}");
|
||||
TODO_ASSERT_EQUALS("[test.cpp:4]: (portability) Undefined behaviour, when 'i' is -20 the pointer arithmetic 'x-i' is out of bounds.\n", "", errout.str());
|
||||
|
||||
check("void f(const char *x[10]) {\n"
|
||||
" return x-4;\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void strcat1() {
|
||||
|
|
Loading…
Reference in New Issue