diff --git a/lib/checkautovariables.cpp b/lib/checkautovariables.cpp index b0b12c247..4b435d73f 100644 --- a/lib/checkautovariables.cpp +++ b/lib/checkautovariables.cpp @@ -179,7 +179,7 @@ static bool isAddressOfLocalVariableRecursive(const Token *expr) const Token *op = expr->astOperand1(); bool deref = false; while (Token::Match(op, ".|[")) { - if (op->str() == "[") + if (op->str() == "[" || op->originalName() == "->") deref = true; op = op->astOperand1(); } diff --git a/test/testautovariables.cpp b/test/testautovariables.cpp index fc5ca62da..da9543288 100644 --- a/test/testautovariables.cpp +++ b/test/testautovariables.cpp @@ -1315,6 +1315,16 @@ private: "}"); ASSERT_EQUALS("", errout.str()); + + check("struct s { void *p; };\n" + "extern struct s* f(void);\n" + "void g(void **q)\n" + "{\n" + " struct s *r = f();\n" + " *q = &r->p;\n" + "}\n"); + + ASSERT_EQUALS("", errout.str()); } void testconstructor() { // Ticket #5478 - crash while checking a constructor