Fixed #5636 (FP: matrix out of bounds)

This commit is contained in:
Daniel Marjamäki 2014-05-03 18:12:06 +02:00
parent 2f3f42d7f1
commit ed1d63ffc0
2 changed files with 7 additions and 1 deletions

View File

@ -1170,7 +1170,7 @@ void CheckBufferOverrun::valueFlowCheckArrayIndex(const Token * const tok, const
bool addressOf = false;
{
const Token *tok2 = tok->astParent();
while (Token::Match(tok2, "%var%|.|::"))
while (Token::Match(tok2, "%var%|.|::|["))
tok2 = tok2->astParent();
addressOf = Token::Match(tok2, "&") && !(tok2->astOperand1() && tok2->astOperand2());
}

View File

@ -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());
check("void f() {\n"
" int a[2][2];\n"
" p = &a[2][0];\n"
"}");
ASSERT_EQUALS("", errout.str());
// unknown dim..
check("void f()\n"
"{\n"