diff --git a/lib/checkother.cpp b/lib/checkother.cpp index a664157ac..77ec55a7f 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -1399,7 +1399,8 @@ private: } // reading 2nd parameter.. - if (Token::Match(&tok, "strcpy|strncpy ( %any% , %var%")) + if (Token::Match(&tok, "strcpy ( %any% , %var% ) ") || + Token::Match(&tok, "strncpy ( %any% , %var% ,")) { use_array(foundError, checks, tok.tokAt(4)); } diff --git a/test/testother.cpp b/test/testother.cpp index 6bf53851e..77147a532 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -1286,6 +1286,14 @@ private: " int x = a;\n" "}\n"); ASSERT_EQUALS("", errout.str()); + + checkUninitVar("void f(struct blame_entry *ent)\n" + "{\n" + " struct origin *suspect = ent->suspect;\n" + " char hex[41];\n" + " strcpy(hex, sha1_to_hex(suspect->commit->object.sha1));\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); }