diff --git a/lib/checkleakautovar.cpp b/lib/checkleakautovar.cpp index b2c9d08725b..b40e0a97cfd 100644 --- a/lib/checkleakautovar.cpp +++ b/lib/checkleakautovar.cpp @@ -281,7 +281,7 @@ static const Token * isFunctionCall(const Token * nameToken) nameToken = nameToken->link()->next(); } // check for '(' - if (nameToken && nameToken->link() && nameToken->str() == "(") { + if (nameToken && nameToken->link() && !nameToken->isCast() && nameToken->str() == "(") { // returning opening parenthesis pointer return nameToken; } diff --git a/test/testleakautovar.cpp b/test/testleakautovar.cpp index 878253536e6..ea012176990 100644 --- a/test/testleakautovar.cpp +++ b/test/testleakautovar.cpp @@ -128,6 +128,7 @@ class TestLeakAutoVar : public TestFixture { TEST_CASE(doublefree12); // #10502 TEST_CASE(doublefree13); // #11008 TEST_CASE(doublefree14); // #9708 + TEST_CASE(doublefree15); // exit TEST_CASE(exit1); @@ -1528,6 +1529,13 @@ class TestLeakAutoVar : public TestFixture { ASSERT_EQUALS("", errout.str()); } + void doublefree15() { // #11966 + check("void f(FILE* fp) {\n" + " static_cast(fclose(fp));\n" + "}", true); + ASSERT_EQUALS("", errout.str()); + } + void exit1() { check("void f() {\n" " char *p = malloc(10);\n"