File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -107,6 +107,7 @@ void CheckFunctions::invalidFunctionUsage()
107107 const SymbolDatabase* symbolDatabase = mTokenizer ->getSymbolDatabase ();
108108 for (const Scope *scope : symbolDatabase->functionScopes ) {
109109 for (const Token* tok = scope->bodyStart ->next (); tok != scope->bodyEnd ; tok = tok->next ()) {
110+ tok = skipUnreachableBranch (tok);
110111 if (!Token::Match (tok, " %name% ( !!)" ))
111112 continue ;
112113 const Token * const functionToken = tok;
Original file line number Diff line number Diff line change @@ -55,6 +55,9 @@ class TestFunctions : public TestFixture {
5555 TEST_CASE (invalidFunctionUsage1);
5656 TEST_CASE (invalidFunctionUsageStrings);
5757
58+ // Invalid function argument
59+ TEST_CASE (invalidFunctionArg1);
60+
5861 // Math function usage
5962 TEST_CASE (mathfunctionCall_fmod);
6063 TEST_CASE (mathfunctionCall_sqrt);
@@ -755,6 +758,21 @@ class TestFunctions : public TestFixture {
755758 ASSERT_EQUALS (" [test.c:1]: (error) Invalid puts() argument nr 1. A nul-terminated string is required.\n " , errout_str ());
756759 }
757760
761+ void invalidFunctionArg1 () {
762+ const Settings settingsUnix32 = settingsBuilder (settings).platform (Platform::Unix32).build ();
763+ check (" int main() {\n "
764+ " char tgt[7];\n "
765+ " char src[7+1] = \" 7777777\" ;\n "
766+ " if (sizeof tgt <= sizeof src) {\n "
767+ " memmove(&tgt, &src, sizeof tgt);\n "
768+ " } else {\n "
769+ " memmove(&tgt, &src, sizeof src);\n "
770+ " memset(&tgt + sizeof src, ' ', sizeof tgt - sizeof src);\n "
771+ " }\n "
772+ " }\n " , false , &settingsUnix32);
773+ ASSERT_EQUALS (" " , errout_str ());
774+ }
775+
758776 void mathfunctionCall_sqrt () {
759777 // sqrt, sqrtf, sqrtl
760778 check (" void foo()\n "
You can’t perform that action at this time.
0 commit comments