Fixed #2088 ([test.c:12]: (error) Buffer access out-of-bounds: l)
This commit is contained in:
parent
4f0cda235a
commit
9e15c4ef38
|
@ -1815,6 +1815,10 @@ bool CheckBufferOverrun::ArrayInfo::declare(const Token *tok, const Tokenizer &t
|
||||||
_element_size = tokenizer.sizeOfType(vartok);
|
_element_size = tokenizer.sizeOfType(vartok);
|
||||||
vartok = vartok->next();
|
vartok = vartok->next();
|
||||||
}
|
}
|
||||||
|
else if (tok->str() == "struct")
|
||||||
|
{
|
||||||
|
_element_size = 100;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_element_size = tokenizer.sizeOfType(tok);
|
_element_size = tokenizer.sizeOfType(tok);
|
||||||
|
|
|
@ -126,6 +126,7 @@ private:
|
||||||
TEST_CASE(buffer_overrun_13);
|
TEST_CASE(buffer_overrun_13);
|
||||||
TEST_CASE(buffer_overrun_14);
|
TEST_CASE(buffer_overrun_14);
|
||||||
TEST_CASE(buffer_overrun_15); // ticket #1787
|
TEST_CASE(buffer_overrun_15); // ticket #1787
|
||||||
|
TEST_CASE(buffer_overrun_16);
|
||||||
|
|
||||||
TEST_CASE(sprintf1);
|
TEST_CASE(sprintf1);
|
||||||
TEST_CASE(sprintf2);
|
TEST_CASE(sprintf2);
|
||||||
|
@ -1685,6 +1686,15 @@ private:
|
||||||
ASSERT_EQUALS("[test.cpp:7]: (error) Buffer access out-of-bounds\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:7]: (error) Buffer access out-of-bounds\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void buffer_overrun_16()
|
||||||
|
{
|
||||||
|
check("void f() {\n"
|
||||||
|
" struct Foo foo[5];\n"
|
||||||
|
" memset(foo, 0, sizeof(foo));\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
}
|
||||||
|
|
||||||
void sprintf1()
|
void sprintf1()
|
||||||
{
|
{
|
||||||
check("void f()\n"
|
check("void f()\n"
|
||||||
|
|
Loading…
Reference in New Issue