Fixed #2109 (false positive: buffer overrun)
This commit is contained in:
parent
f1640d6731
commit
2ca7dbc004
|
@ -1474,6 +1474,9 @@ unsigned int CheckBufferOverrun::countSprintfLength(const std::string &input_str
|
|||
|
||||
void CheckBufferOverrun::checkSprintfCall(const Token *tok, const unsigned int size)
|
||||
{
|
||||
if (size == 0)
|
||||
return;
|
||||
|
||||
const Token *end = tok->next()->link();
|
||||
|
||||
// Count the number of tokens in the buffer variable's name
|
||||
|
|
|
@ -136,6 +136,7 @@ private:
|
|||
TEST_CASE(sprintf6);
|
||||
TEST_CASE(sprintf7);
|
||||
TEST_CASE(sprintf8);
|
||||
TEST_CASE(sprintf9);
|
||||
|
||||
TEST_CASE(snprintf1);
|
||||
TEST_CASE(snprintf2);
|
||||
|
@ -1824,6 +1825,16 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void sprintf9()
|
||||
{
|
||||
check("void f()\n"
|
||||
"{\n"
|
||||
" gchar str[3];\n"
|
||||
" sprintf(str, \"1\");\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void snprintf1()
|
||||
{
|
||||
check("void f()\n"
|
||||
|
|
Loading…
Reference in New Issue