#2133 (cppcheck: floating point exception)

This commit is contained in:
Daniel Marjamäki 2010-10-26 20:05:34 +02:00
parent 6200d4505a
commit 79583ee45d
2 changed files with 10 additions and 1 deletions

View File

@ -712,7 +712,7 @@ void CheckBufferOverrun::checkScope(const Token *tok, const std::vector<std::str
// memset, memcmp, memcpy, strncpy, fgets..
if (varid == 0)
if (varid == 0 && size > 0)
{
ArrayInfo arrayInfo(0U, varnames, total_size / size, size);
if (Token::Match(tok, ("%var% ( " + varnames + " ,").c_str()))

View File

@ -1036,6 +1036,15 @@ private:
" x(obj.delay, 123);\n"
"}\n");
ASSERT_EQUALS("[test.cpp:11] -> [test.cpp:6]: (error) Array 'obj . delay[3]' index 4 out of bounds\n", errout.str());
check("struct s1 {\n"
" float a[0];\n"
"};\n"
"\n"
"void f() {\n"
" struct s1 *obj;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
void array_index_multidim()