Fixed #5149 (false positive: (error) Dereferencing 'memory' after it is deallocated / released)

This commit is contained in:
Daniel Marjamäki 2013-12-14 07:37:24 +01:00
parent 80dec5a976
commit 57ecdd693c
2 changed files with 10 additions and 0 deletions

View File

@ -597,6 +597,8 @@ const char * CheckMemoryLeakInFunction::call_func(const Token *tok, std::list<co
return "use";
else if (tok2->strAt(1) == "=")
return "assign";
else if (tok->str()=="printf")
return "use"; // <- it is not certain printf dereference the pointer TODO: check the format string
else
return "use_";
}

View File

@ -2998,6 +2998,14 @@ private:
"}");
ASSERT_EQUALS("", errout.str());
check("void f()\n"
"{\n"
" char *s = new char[100];\n"
" delete [] s;\n"
" printf(\"%p\\n\", s);\n"
"}");
ASSERT_EQUALS("", errout.str());
// The pointer to the pointer is valid..
check("void f()\n"
"{\n"