diff --git a/lib/astutils.cpp b/lib/astutils.cpp index 405e8fd6b..c0e906d27 100644 --- a/lib/astutils.cpp +++ b/lib/astutils.cpp @@ -1669,6 +1669,8 @@ const Token * getTokenArgumentFunction(const Token * tok, int& argn) if (!Token::Match(tok, "{|(")) return nullptr; tok = tok->astOperand1(); + while (tok && (tok->isUnaryOp("*") || tok->str() == "[")) + tok = tok->astOperand1(); while (Token::simpleMatch(tok, ".")) tok = tok->astOperand2(); while (Token::simpleMatch(tok, "::")) { diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index f12698305..c62ac0508 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -4667,6 +4667,21 @@ private: " printf(\"\", value);\n" "}\n"); ASSERT_EQUALS("", errout.str()); + + // function pointers + valueFlowUninit("int f (const struct FileFuncDefs *ffd) {\n" // #10279 + " int c;\n" + " (*ffd->zread)(&c, 1);\n" + " return c;\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + + valueFlowUninit("int foo(unsigned int code) {\n" // #10279 + " int res;\n\n" + " (* (utility_table[code])) (&res);\n" + " return (res);\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); } void uninitvar_ipa() {