diff --git a/lib/checkuninitvar.cpp b/lib/checkuninitvar.cpp index 3a14b4b39..e4d982d3a 100644 --- a/lib/checkuninitvar.cpp +++ b/lib/checkuninitvar.cpp @@ -703,7 +703,8 @@ private: } // function call via function pointer - if (Token::Match(&tok, "( * %var% ) (")) { + if (Token::Match(&tok, "( * %var% ) (") || + (Token::Match(&tok, "( *| %var% .|::") && Token::Match(tok.link()->tokAt(-2), ".|:: %var% ) ("))) { // is the variable passed as a parameter to some function? unsigned int parlevel = 0; for (const Token *tok2 = tok.link()->next(); tok2; tok2 = tok2->next()) { diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index 67faa1ca3..d58eb238a 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -1502,6 +1502,14 @@ private: "}\n"); ASSERT_EQUALS("", errout.str()); + // #3222 - calling function through function pointer + checkUninitVar("char f() {\n" + " char buffer[100];\n" + " (foo.init)(buffer);\n" + " return buffer[0];\n" + "}"); + ASSERT_EQUALS("", errout.str()); + // using uninitialized function pointer.. checkUninitVar("void foo()\n" "{\n"