From f23668dfccd3c5fad5a0c974717acf8ff59cc172 Mon Sep 17 00:00:00 2001 From: PKEuS Date: Wed, 4 May 2016 12:14:42 +0200 Subject: [PATCH] Fixed false positive doubleFree (#7401) --- lib/checkleakautovar.cpp | 2 +- test/testleakautovar.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/checkleakautovar.cpp b/lib/checkleakautovar.cpp index 82d9bc6ad..a9f1eaff0 100644 --- a/lib/checkleakautovar.cpp +++ b/lib/checkleakautovar.cpp @@ -516,7 +516,7 @@ void CheckLeakAutoVar::functionCall(const Token *tok, VarInfo *varInfo, const Va if (_tokenizer->isCPP() && arg->str() == "new") arg = arg->next(); - if (Token::Match(arg, "%var% [-,)]") || Token::Match(arg, "& %var%")) { + if (Token::Match(arg, "%var% [-,)] !!.") || Token::Match(arg, "& %var%")) { // goto variable if (arg->str() == "&") diff --git a/test/testleakautovar.cpp b/test/testleakautovar.cpp index 146de2698..a4ba55e38 100644 --- a/test/testleakautovar.cpp +++ b/test/testleakautovar.cpp @@ -760,6 +760,13 @@ private: " }\n" "};", true); ASSERT_EQUALS("", errout.str()); + + // #7401 + check("void pCodeLabelDestruct(pCode *pc) {\n" + " free(PCL(pc)->label);\n" + " free(pc);\n" + "}"); + ASSERT_EQUALS("", errout.str()); } void doublefree2() { // #3891