Fixed #2323 (false positive: Buffer access out of bounds)
This commit is contained in:
parent
fc9c450eed
commit
f6c00fc478
|
@ -1032,7 +1032,7 @@ void CheckBufferOverrun::checkScope(const Token *tok, const ArrayInfo &arrayInfo
|
|||
}
|
||||
|
||||
// Detect few strcat() calls
|
||||
if (Token::Match(tok, "strcat ( %varid% , %str% ) ;", arrayInfo.varid))
|
||||
if (total_size > 0 && Token::Match(tok, "strcat ( %varid% , %str% ) ;", arrayInfo.varid))
|
||||
{
|
||||
size_t charactersAppend = 0;
|
||||
const Token *tok2 = tok;
|
||||
|
|
|
@ -155,6 +155,7 @@ private:
|
|||
|
||||
TEST_CASE(strcat1);
|
||||
TEST_CASE(strcat2);
|
||||
TEST_CASE(strcat3);
|
||||
|
||||
TEST_CASE(memfunc1); // memchr/memset/memcpy
|
||||
TEST_CASE(memfunc2);
|
||||
|
@ -2033,6 +2034,15 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void strcat3()
|
||||
{
|
||||
check("void f() {\n"
|
||||
" INT str[10];\n"
|
||||
" strcat(str, \"aa\");\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
||||
// memchr/memset/memcpy/etc
|
||||
void memfunc1()
|
||||
|
|
Loading…
Reference in New Issue