astyle fix
This commit is contained in:
parent
c4d1d47f6b
commit
c28b365ea0
|
@ -618,7 +618,7 @@ void CheckBufferOverrun::checkScope(const Token *tok, const std::vector<std::str
|
||||||
Token::Match(tok, "fread|fwrite ( %varid% , %num% , %num% , %any% )", varid) &&
|
Token::Match(tok, "fread|fwrite ( %varid% , %num% , %num% , %any% )", varid) &&
|
||||||
MathLib::isInt(tok->strAt(6)))
|
MathLib::isInt(tok->strAt(6)))
|
||||||
{
|
{
|
||||||
long len = MathLib::toLongNumber(tok->strAt(4))*MathLib::toLongNumber(tok->strAt(6));
|
long len = MathLib::toLongNumber(tok->strAt(4)) * MathLib::toLongNumber(tok->strAt(6));
|
||||||
if (len < 0 || len > total_size)
|
if (len < 0 || len > total_size)
|
||||||
{
|
{
|
||||||
bufferOverrun(tok);
|
bufferOverrun(tok);
|
||||||
|
|
|
@ -1073,30 +1073,30 @@ private:
|
||||||
// fread
|
// fread
|
||||||
check("void f(FILE* fd)\n"
|
check("void f(FILE* fd)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"char str[3];\n"
|
"char str[3];\n"
|
||||||
"fread(str,sizeof(char),4,fd);\n"
|
"fread(str,sizeof(char),4,fd);\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("[test.cpp:4]: (error) Buffer access out-of-bounds\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:4]: (error) Buffer access out-of-bounds\n", errout.str());
|
||||||
|
|
||||||
check("void f(FILE* fd)\n"
|
check("void f(FILE* fd)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"char str[3*sizeof(char)];\n"
|
"char str[3*sizeof(char)];\n"
|
||||||
"fread(str,sizeof(char),3,fd);\n"
|
"fread(str,sizeof(char),3,fd);\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
// fwrite
|
// fwrite
|
||||||
check("void f(FILE* fd)\n"
|
check("void f(FILE* fd)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"char str[3];\n"
|
"char str[3];\n"
|
||||||
"fwrite(str,sizeof(char),4,fd);\n"
|
"fwrite(str,sizeof(char),4,fd);\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("[test.cpp:4]: (error) Buffer access out-of-bounds\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:4]: (error) Buffer access out-of-bounds\n", errout.str());
|
||||||
|
|
||||||
check("void f(FILE* fd)\n"
|
check("void f(FILE* fd)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"char str[3*sizeof(char)];\n"
|
"char str[3*sizeof(char)];\n"
|
||||||
"fwrite(str,sizeof(char),3,fd);\n"
|
"fwrite(str,sizeof(char),3,fd);\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue