Fixed #1536 (###### If you see this, there is a bug ###### Token::Match() - varid was 0)
This commit is contained in:
parent
c3edc5fd89
commit
0bddd1977f
|
@ -816,6 +816,10 @@ void CheckBufferOverrun::checkGlobalAndLocalVariable()
|
|||
if (tok->next()->str() == "*")
|
||||
++varpos;
|
||||
|
||||
// make sure the variable is defined
|
||||
if (tok->tokAt(varpos + 2)->varId() == 0)
|
||||
continue; // FIXME we loose the check for negative index when we bail
|
||||
|
||||
// get maximum size from type
|
||||
// find where this token is defined
|
||||
const Token *index_type = Token::findmatch(_tokenizer->tokens(), "%varid%", tok->tokAt(varpos + 2)->varId());
|
||||
|
|
|
@ -94,6 +94,7 @@ private:
|
|||
TEST_CASE(array_index_22);
|
||||
TEST_CASE(array_index_23);
|
||||
TEST_CASE(array_index_24); // ticket #1492
|
||||
TEST_CASE(array_index_25); // ticket #1536
|
||||
TEST_CASE(array_index_multidim);
|
||||
TEST_CASE(array_index_switch_in_for);
|
||||
TEST_CASE(array_index_calculation);
|
||||
|
@ -794,6 +795,16 @@ private:
|
|||
"[test.cpp:4]: (error) Array 'a[65536]' index 65536 out of bounds\n", errout.str());
|
||||
}
|
||||
|
||||
void array_index_25()
|
||||
{
|
||||
// ticket #1536
|
||||
check("void foo()\n"
|
||||
"{\n"
|
||||
" long l[SOME_SIZE];\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void array_index_multidim()
|
||||
{
|
||||
check("void f()\n"
|
||||
|
|
Loading…
Reference in New Issue