Fixed #6816 (FP: buffer overflow, checkminsizes of array with string value)
This commit is contained in:
parent
b50f554b28
commit
c5bbea2994
|
@ -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;
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue