diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 4b609234d..e6297e608 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -1664,7 +1664,8 @@ private: if (Token::simpleMatch(tok.next(), ".")) { - use_pointer(foundError, checks, &tok); + if (!Token::Match(tok.previous(), "[;{}] %var% . %var% =")) + use_pointer(foundError, checks, &tok); return &tok; } diff --git a/test/testother.cpp b/test/testother.cpp index 4c89f418f..159fddedd 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -1342,6 +1342,13 @@ private: "}\n"); ASSERT_EQUALS("", errout.str()); + checkUninitVar("void foo()\n" + "{\n" + " ABC *abc = malloc(100);\n" + " abc->a = 123;\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + // struct.. checkUninitVar("void f()\n" "{\n"