Fixed #5149 (false positive: (error) Dereferencing 'memory' after it is deallocated / released)
This commit is contained in:
parent
80dec5a976
commit
57ecdd693c
|
@ -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_";
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue