Fixed #740 (False positive, buffer overrun with --all)
Regression since 07f41f4563
commit.
http://sourceforge.net/apps/trac/cppcheck/ticket/740
This commit is contained in:
parent
f62e5f1672
commit
e8c83613e4
|
@ -264,7 +264,7 @@ void CheckBufferOverrun::checkScope(const Token *tok, const char *varname[], con
|
||||||
// Get index variable and stopsize.
|
// Get index variable and stopsize.
|
||||||
const char *strindex = tok2->str().c_str();
|
const char *strindex = tok2->str().c_str();
|
||||||
bool condition_out_of_bounds = true;
|
bool condition_out_of_bounds = true;
|
||||||
if (value < size)
|
if (value <= size)
|
||||||
condition_out_of_bounds = false;
|
condition_out_of_bounds = false;
|
||||||
|
|
||||||
const Token *tok3 = tok2->tokAt(4);
|
const Token *tok3 = tok2->tokAt(4);
|
||||||
|
|
|
@ -97,6 +97,7 @@ private:
|
||||||
TEST_CASE(buffer_overrun_7);
|
TEST_CASE(buffer_overrun_7);
|
||||||
TEST_CASE(buffer_overrun_8);
|
TEST_CASE(buffer_overrun_8);
|
||||||
TEST_CASE(buffer_overrun_9);
|
TEST_CASE(buffer_overrun_9);
|
||||||
|
TEST_CASE(buffer_overrun_10);
|
||||||
|
|
||||||
TEST_CASE(sprintf1);
|
TEST_CASE(sprintf1);
|
||||||
TEST_CASE(sprintf2);
|
TEST_CASE(sprintf2);
|
||||||
|
@ -645,6 +646,20 @@ private:
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void buffer_overrun_10()
|
||||||
|
{
|
||||||
|
// ticket #740
|
||||||
|
check("void f()\n"
|
||||||
|
"{\n"
|
||||||
|
" char a[4];\n"
|
||||||
|
" for (int i = 0; i < 4; i++)\n"
|
||||||
|
" {\n"
|
||||||
|
" char b = a[i];\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void sprintf1()
|
void sprintf1()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue