diff --git a/lib/checkother.cpp b/lib/checkother.cpp index d056d46bf..16b33c702 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -2154,7 +2154,10 @@ private: if (Token::simpleMatch(tok.next(), ".")) { - if (!Token::Match(tok.previous(), "[;{}] %var% . %var% =")) + const Token *tok2 = tok.next(); + while (Token::Match(tok2, ". %var%")) + tok2 = tok2->tokAt(2); + if (tok2 && tok2->str() != "=") use_pointer(foundError, checks, &tok); else bailOutVar(checks, tok.varId()); diff --git a/test/testother.cpp b/test/testother.cpp index 111476976..a459be7ff 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -1647,6 +1647,13 @@ private: "}\n"); ASSERT_EQUALS("", errout.str()); + checkUninitVar("void foo()\n" + "{\n" + " ABC *abc = malloc(100);\n" + " abc->a.word = 123;\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + checkUninitVar("void foo()\n" "{\n" " ABC *abc = malloc(100);\n"