Fixed #6816 (FP: buffer overflow, checkminsizes of array with string value)

This commit is contained in:
Daniel Marjamäki 2015-07-27 16:39:41 +02:00
parent b50f554b28
commit c5bbea2994
2 changed files with 8 additions and 0 deletions

View File

@ -1593,6 +1593,8 @@ void CheckBufferOverrun::checkStringArgument()
for (const Token *argtok = tok->tokAt(2); argtok; argtok = argtok->nextArgument(), argnr++) {
if (!Token::Match(argtok, "%name%|%str% ,|)"))
continue;
if (argtok->variable() && !argtok->variable()->isPointer())
continue;
const Token *strtoken = argtok->getValueTokenMinStrSize();
if (!strtoken)
continue;

View File

@ -3094,6 +3094,12 @@ private:
" mymemset(temp, \"abc\", 4);\n"
"}", settings);
ASSERT_EQUALS("", errout.str());
check("void f() {\n" // #6816 - fp when array has known string value
" const char c[10] = \"c\";\n"
" mymemset(c, 0, 10);\n"
"}", settings);
ASSERT_EQUALS("", errout.str());
}
void minsize_sizeof() {