From 7f42ed3ad0f8e0a3b1b6e3ac69e3c91b329eb53a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 7 Mar 2010 09:08:52 +0100 Subject: [PATCH] Fixed #1472 (false positive: Data is allocated but not initialized: service) --- lib/checkother.cpp | 5 ++++- test/testother.cpp | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-) 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"