Fixed #5636 (FP: matrix out of bounds)
This commit is contained in:
parent
2f3f42d7f1
commit
ed1d63ffc0
|
@ -1170,7 +1170,7 @@ void CheckBufferOverrun::valueFlowCheckArrayIndex(const Token * const tok, const
|
||||||
bool addressOf = false;
|
bool addressOf = false;
|
||||||
{
|
{
|
||||||
const Token *tok2 = tok->astParent();
|
const Token *tok2 = tok->astParent();
|
||||||
while (Token::Match(tok2, "%var%|.|::"))
|
while (Token::Match(tok2, "%var%|.|::|["))
|
||||||
tok2 = tok2->astParent();
|
tok2 = tok2->astParent();
|
||||||
addressOf = Token::Match(tok2, "&") && !(tok2->astOperand1() && tok2->astOperand2());
|
addressOf = Token::Match(tok2, "&") && !(tok2->astOperand1() && tok2->astOperand2());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1633,6 +1633,12 @@ private:
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:3]: (error) Array 'a[6][6][6]' index a[6][6][2] out of bounds.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:3]: (error) Array 'a[6][6][6]' index a[6][6][2] out of bounds.\n", errout.str());
|
||||||
|
|
||||||
|
check("void f() {\n"
|
||||||
|
" int a[2][2];\n"
|
||||||
|
" p = &a[2][0];\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
// unknown dim..
|
// unknown dim..
|
||||||
check("void f()\n"
|
check("void f()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
|
|
Loading…
Reference in New Issue