Fixed #7104 (False positive arrayIndexOutOfBounds)
This commit is contained in:
parent
fdb596fa05
commit
7d6e1974eb
|
@ -1089,7 +1089,7 @@ void CheckBufferOverrun::checkGlobalAndLocalVariable()
|
||||||
if (!it->tokvalue)
|
if (!it->tokvalue)
|
||||||
continue;
|
continue;
|
||||||
const Variable *var = it->tokvalue->variable();
|
const Variable *var = it->tokvalue->variable();
|
||||||
if (var && var->isArray() && var->dimensions().size() == 1U && value->intvalue > var->dimension(0)) {
|
if (var && var->isArray() && var->dimensions().size() == 1U && var->dimensionKnown(0) && value->intvalue > var->dimension(0)) {
|
||||||
std::list<const Token *> callstack;
|
std::list<const Token *> callstack;
|
||||||
callstack.push_back(it->tokvalue);
|
callstack.push_back(it->tokvalue);
|
||||||
callstack.push_back(tok);
|
callstack.push_back(tok);
|
||||||
|
|
|
@ -2065,6 +2065,13 @@ private:
|
||||||
" p[20] = 0;\n"
|
" p[20] = 0;\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:4]: (error) Array 'a[10]' accessed at index 20, which is out of bounds.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:4]: (error) Array 'a[10]' accessed at index 20, which is out of bounds.\n", errout.str());
|
||||||
|
|
||||||
|
check("void f() {\n"
|
||||||
|
" int a[X];\n"
|
||||||
|
" int *p = a;\n"
|
||||||
|
" p[20] = 0;\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void array_index_function_parameter() {
|
void array_index_function_parameter() {
|
||||||
|
|
Loading…
Reference in New Issue