From f38105829383f8b33b1ef3f350b6b836528dc9e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Tue, 25 Dec 2012 13:58:15 +0100 Subject: [PATCH] Uninitialized variables: fixed FP when there are suspicious function calls where type** is converted to type* --- lib/checkuninitvar.cpp | 2 +- test/testuninitvar.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/checkuninitvar.cpp b/lib/checkuninitvar.cpp index 427b73658..34acd00c1 100644 --- a/lib/checkuninitvar.cpp +++ b/lib/checkuninitvar.cpp @@ -1382,7 +1382,7 @@ bool CheckUninitVar::isVariableUsage(const Scope* scope, const Token *vartok, bo return true; if (Token::Match(argStart, "const %type% & %var% [,)]")) return true; - if (pointer && Token::Match(argStart, "%type% * %var% [,)]")) + if (pointer && !address && Token::Match(argStart, "%type% * %var% [,)]")) return true; if ((pointer || address) && Token::Match(argStart, "const %type% * %var% [,)]")) return true; diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index e5426b29e..d2e737c58 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -2452,6 +2452,13 @@ private: "}"); ASSERT_EQUALS("", errout.str()); + checkUninitVar2("void a(char *c);\n" // address of pointer (suspicious cast to pointer) => no error + "void b() {\n" + " char *c;\n" + " a(&c);\n" + "}"); + ASSERT_EQUALS("", errout.str()); + checkUninitVar2("void a(const char **c);\n" // const address of pointer => no error "void b() {\n" " const char *c;\n"