From 7c52c8683dcf490a92c829496620df24f80b4b4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 9 May 2010 07:48:52 +0200 Subject: [PATCH] Fixed #1662 (false positive: Data is allocated but not initialized, when using sprintf) --- lib/checkother.cpp | 2 +- test/testother.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 0debf8f99..a18c32110 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -2965,7 +2965,7 @@ private: for (std::list::const_iterator it = var2.begin(); it != var2.end(); ++it) { if (std::find(var.begin(), var.end(), *it) == var.end()) - use_pointer(checks, *it); + use_dead_pointer(checks, *it); } } diff --git a/test/testother.cpp b/test/testother.cpp index fff9e6146..9ee552fd6 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -2022,6 +2022,13 @@ private: "}\n"); ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: p\n", errout.str()); + checkUninitVar("void foo(const char *s)\n" + "{\n" + " char *p = malloc(100);\n" + " memcpy(p, s, 100);\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + // using uninitialized function pointer.. checkUninitVar("void foo()\n" "{\n"