diff --git a/src/checkother.cpp b/src/checkother.cpp index 78c7a5317..7c36772a6 100644 --- a/src/checkother.cpp +++ b/src/checkother.cpp @@ -344,7 +344,7 @@ void CheckOther::InvalidFunctionUsage() tok2 = tok2->next(); // is any source buffer overlapping the target buffer? - unsigned int parlevel = 0; + int parlevel = 0; while ((tok2 = tok2->next()) != NULL) { if (tok2->str() == "(") diff --git a/test/testother.cpp b/test/testother.cpp index f6e34ed65..544f72515 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -39,6 +39,7 @@ private: TEST_CASE(sprintf1); // Dangerous usage of sprintf TEST_CASE(sprintf2); + TEST_CASE(sprintf3); } void check(const char code[]) @@ -125,6 +126,18 @@ private: "}\n"); ASSERT_EQUALS(std::string(""), errout.str()); } + + void sprintf3() + { + sprintfUsage("void foo()\n" + "{\n" + " char buf[100];\n" + " sprintf(buf,\"%i\",sizeof(buf));\n" + " if (buf[0]);\n" + "}\n"); + ASSERT_EQUALS(std::string(""), errout.str()); + } + }; REGISTER_TEST(TestOther)