Refactoring of 'CheckBufferOverrun.cpp'
This commit is contained in:
parent
41252ac45a
commit
fcff7a4052
|
@ -259,7 +259,7 @@ static void CheckBufferOverrun_CheckScope( const TOKEN *tok, const char *varname
|
||||||
|
|
||||||
// Function call..
|
// Function call..
|
||||||
// Todo: Handle struct member variables..
|
// Todo: Handle struct member variables..
|
||||||
if ( varc == 0 && match( tok, "var (" ) )
|
if ( match( tok, "var (" ) )
|
||||||
{
|
{
|
||||||
// Don't make recursive checking..
|
// Don't make recursive checking..
|
||||||
if (std::find(CallStack.begin(), CallStack.end(), tok) != CallStack.end())
|
if (std::find(CallStack.begin(), CallStack.end(), tok) != CallStack.end())
|
||||||
|
@ -290,8 +290,8 @@ static void CheckBufferOverrun_CheckScope( const TOKEN *tok, const char *varname
|
||||||
|
|
||||||
if ( parlevel == 1 &&
|
if ( parlevel == 1 &&
|
||||||
strchr( "(,", *getstr(tok2,0) ) &&
|
strchr( "(,", *getstr(tok2,0) ) &&
|
||||||
strcmp( varname[0], getstr(tok2, 1) ) == 0 &&
|
Match1( tok2->next, "%var1%", varname ) &&
|
||||||
strchr( ",)", *getstr(tok2,2) ) )
|
strchr( ",)", *getstr(tok2, 2+varc) ) )
|
||||||
{
|
{
|
||||||
par++;
|
par++;
|
||||||
break;
|
break;
|
||||||
|
|
19
tests.cpp
19
tests.cpp
|
@ -431,6 +431,25 @@ static void buffer_overrun()
|
||||||
check( CheckBufferOverrun, __LINE__, test11, "[test.cpp:9] -> [test.cpp:3]: Array index out of bounds\n" );
|
check( CheckBufferOverrun, __LINE__, test11, "[test.cpp:9] -> [test.cpp:3]: Array index out of bounds\n" );
|
||||||
|
|
||||||
|
|
||||||
|
const char test12[] = "struct ABC\n"
|
||||||
|
"{\n"
|
||||||
|
" char str[10];\n"
|
||||||
|
"};\n"
|
||||||
|
"\n"
|
||||||
|
"static void memclr( char *data )\n"
|
||||||
|
"{\n"
|
||||||
|
" data[10] = 0;\n"
|
||||||
|
"}\n"
|
||||||
|
"\n"
|
||||||
|
"static void f(ABC *abc)\n"
|
||||||
|
"{\n"
|
||||||
|
" memclr(abc->str);\n"
|
||||||
|
"}\n";
|
||||||
|
check( CheckBufferOverrun, __LINE__, test12, "[test.cpp:13] -> [test.cpp:8]: Array index out of bounds\n" );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue