Fixed #2097 (false positive: buffer access out of bounds)
This commit is contained in:
parent
e11d9f1628
commit
ba2b986ece
|
@ -589,6 +589,10 @@ void CheckBufferOverrun::checkFunctionCall(const Token &tok, unsigned int par, c
|
|||
|
||||
if (ftok->varId() == parameterVarId)
|
||||
{
|
||||
if (Token::Match(ftok->previous(), "-- %var%") ||
|
||||
Token::Match(ftok, "%var% --"))
|
||||
break;
|
||||
|
||||
if (Token::Match(ftok->previous(), "[=+-*/;{}] %var% [ %num% ]"))
|
||||
{
|
||||
long index = MathLib::toLongNumber(ftok->strAt(2));
|
||||
|
|
|
@ -550,6 +550,20 @@ private:
|
|||
" memclr( str, 5 ); // ERROR\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// #2097..
|
||||
check("void foo(int *p)\n"
|
||||
"{\n"
|
||||
" --p;\n"
|
||||
" p[2] = 0;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"void bar()\n"
|
||||
"{\n"
|
||||
" int p[3];\n"
|
||||
" foo(p+1);\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue