Unit Testing: Added unit test for untested code in CheckBufferOverrun. Using memset on struct.

This commit is contained in:
Daniel Marjamäki 2010-04-05 21:50:40 +02:00
parent d3c251f53a
commit 0cffe547f9
1 changed files with 10 additions and 0 deletions

View File

@ -1437,6 +1437,16 @@ private:
// memchr/memset/memcpy/etc // memchr/memset/memcpy/etc
void memfunc() void memfunc()
{ {
check("struct S {\n"
" char a[5];\n"
"};\n"
"void f()\n"
"{\n"
" S s;\n"
" memset(s.a, 0, 10);\n"
"}\n");
ASSERT_EQUALS("[test.cpp:4]: (error) Buffer access out-of-bounds: s.a\n", errout.str());
check("void f()\n" check("void f()\n"
"{\n" "{\n"
" char str[5];\n" " char str[5];\n"