diff --git a/lib/checkbufferoverrun.cpp b/lib/checkbufferoverrun.cpp index 522c4a4fa..722c6a1da 100644 --- a/lib/checkbufferoverrun.cpp +++ b/lib/checkbufferoverrun.cpp @@ -613,12 +613,12 @@ void CheckBufferOverrun::checkScope(const Token *tok, const std::vector Pointer to a block of memory with a minimum size of (size*count) bytes. // size -> Size in bytes of each element to be read. // count -> Number of elements, each one with a size of size bytes. - // stream -> Pointer to a FILE object that specifies an input stream. + // stream -> Pointer to a FILE object that specifies an input stream. if (varid > 0 && Token::Match(tok, "fread|fwrite ( %varid% , %num% , %num% , %any% )", varid) && 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) { bufferOverrun(tok); diff --git a/test/testbufferoverrun.cpp b/test/testbufferoverrun.cpp index 5a344c9cc..507ca5087 100644 --- a/test/testbufferoverrun.cpp +++ b/test/testbufferoverrun.cpp @@ -1073,30 +1073,30 @@ private: // fread check("void f(FILE* fd)\n" "{\n" - "char str[3];\n" - "fread(str,sizeof(char),4,fd);\n" + "char str[3];\n" + "fread(str,sizeof(char),4,fd);\n" "}\n"); ASSERT_EQUALS("[test.cpp:4]: (error) Buffer access out-of-bounds\n", errout.str()); check("void f(FILE* fd)\n" "{\n" - "char str[3*sizeof(char)];\n" - "fread(str,sizeof(char),3,fd);\n" + "char str[3*sizeof(char)];\n" + "fread(str,sizeof(char),3,fd);\n" "}\n"); ASSERT_EQUALS("", errout.str()); // fwrite check("void f(FILE* fd)\n" "{\n" - "char str[3];\n" - "fwrite(str,sizeof(char),4,fd);\n" + "char str[3];\n" + "fwrite(str,sizeof(char),4,fd);\n" "}\n"); ASSERT_EQUALS("[test.cpp:4]: (error) Buffer access out-of-bounds\n", errout.str()); check("void f(FILE* fd)\n" "{\n" - "char str[3*sizeof(char)];\n" - "fwrite(str,sizeof(char),3,fd);\n" + "char str[3*sizeof(char)];\n" + "fwrite(str,sizeof(char),3,fd);\n" "}\n"); ASSERT_EQUALS("", errout.str());