errmsg: added varname to the message "deallocating a deallocated pointer"
This commit is contained in:
parent
121c0ee58f
commit
a5e2787f72
|
@ -1225,7 +1225,7 @@ void CheckMemoryLeakClass::CheckMemoryLeak_CheckScope(const Token *Tok1, const c
|
|||
|
||||
else if ((result = Token::findmatch(tok, "dealloc ; dealloc ;")) != NULL)
|
||||
{
|
||||
_errorLogger->reportErr(ErrorMessage::deallocDealloc(_tokenizer, result->tokAt(2)));
|
||||
_errorLogger->reportErr(ErrorMessage::deallocDealloc(_tokenizer, result->tokAt(2), varname));
|
||||
}
|
||||
|
||||
else if (! Token::findmatch(tok, "dealloc") &&
|
||||
|
|
|
@ -147,9 +147,9 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
static std::string deallocDealloc(const Tokenizer *tokenizer, const Token *Location)
|
||||
static std::string deallocDealloc(const Tokenizer *tokenizer, const Token *Location, const std::string &varname)
|
||||
{
|
||||
return msg1(tokenizer, Location) + "Deallocating a deallocated pointer";
|
||||
return msg1(tokenizer, Location) + "Deallocating a deallocated pointer: " + varname + "";
|
||||
}
|
||||
static bool deallocDealloc(const Settings &s)
|
||||
{
|
||||
|
|
|
@ -1617,7 +1617,7 @@ private:
|
|||
" free(str);\n"
|
||||
" free(str);\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS(std::string("[test.cpp:5]: Deallocating a deallocated pointer\n"), errout.str());
|
||||
ASSERT_EQUALS(std::string("[test.cpp:5]: Deallocating a deallocated pointer: str\n"), errout.str());
|
||||
}
|
||||
|
||||
void freefree2()
|
||||
|
|
|
@ -72,7 +72,7 @@ int main()
|
|||
err.push_back(Message("mismatchAllocDealloc", Message::std, "Mismatching allocation and deallocation: %1", "varname"));
|
||||
err.push_back(Message("memleak", Message::std, "Memory leak: %1", "varname"));
|
||||
err.push_back(Message("resourceLeak", Message::std, "Resource leak: %1", "varname"));
|
||||
err.push_back(Message("deallocDealloc", Message::std, "Deallocating a deallocated pointer"));
|
||||
err.push_back(Message("deallocDealloc", Message::std, "Deallocating a deallocated pointer: %1", "varname"));
|
||||
|
||||
// checkother.cpp..
|
||||
err.push_back(Message("cstyleCast", Message::style, "C-style pointer casting"));
|
||||
|
|
Loading…
Reference in New Issue