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";
|
return "use";
|
||||||
else if (tok2->strAt(1) == "=")
|
else if (tok2->strAt(1) == "=")
|
||||||
return "assign";
|
return "assign";
|
||||||
|
else if (tok->str()=="printf")
|
||||||
|
return "use"; // <- it is not certain printf dereference the pointer TODO: check the format string
|
||||||
else
|
else
|
||||||
return "use_";
|
return "use_";
|
||||||
}
|
}
|
||||||
|
|
|
@ -2998,6 +2998,14 @@ private:
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
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..
|
// The pointer to the pointer is valid..
|
||||||
check("void f()\n"
|
check("void f()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
|
|
Loading…
Reference in New Issue