From 1c0f3ee179e8b7708ef6da6adb69f08c4251520b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 27 Dec 2009 17:35:18 +0100 Subject: [PATCH] Fixed #1154 (false positive: Data is allocated but not initialized) --- lib/checkother.cpp | 3 ++- test/testother.cpp | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) 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"