Fix #903 (false positive: buffer access out of bounds)
http://sourceforge.net/apps/trac/cppcheck/ticket/903
This commit is contained in:
parent
77b676937d
commit
b222ef89be
|
@ -668,6 +668,9 @@ void CheckBufferOverrun::checkGlobalAndLocalVariable()
|
|||
continue;
|
||||
}
|
||||
|
||||
if (varid == 0)
|
||||
continue;
|
||||
|
||||
Token sizeTok;
|
||||
sizeTok.str(type);
|
||||
int total_size = size * _tokenizer->sizeOfType(&sizeTok);
|
||||
|
|
|
@ -296,6 +296,18 @@ private:
|
|||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:6]: (error) Buffer access out-of-bounds\n", errout.str());
|
||||
}
|
||||
|
||||
{
|
||||
check("typedef struct g g2[3];\n"
|
||||
"void foo(char *a)\n"
|
||||
"{\n"
|
||||
" for (int i = 0; i < 4; i++)\n"
|
||||
" {\n"
|
||||
" a[i]=0;\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue