errmsg: added varname to the message "deallocating a deallocated pointer"

This commit is contained in:
Daniel Marjamäki 2009-01-17 11:15:46 +00:00
parent 121c0ee58f
commit a5e2787f72
4 changed files with 5 additions and 5 deletions

View File

@ -1225,7 +1225,7 @@ void CheckMemoryLeakClass::CheckMemoryLeak_CheckScope(const Token *Tok1, const c
else if ((result = Token::findmatch(tok, "dealloc ; dealloc ;")) != NULL) 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") && else if (! Token::findmatch(tok, "dealloc") &&

View File

@ -147,9 +147,9 @@ public:
return true; 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) static bool deallocDealloc(const Settings &s)
{ {

View File

@ -1617,7 +1617,7 @@ private:
" free(str);\n" " free(str);\n"
" free(str);\n" " free(str);\n"
"}\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() void freefree2()

View File

@ -72,7 +72,7 @@ int main()
err.push_back(Message("mismatchAllocDealloc", Message::std, "Mismatching allocation and deallocation: %1", "varname")); 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("memleak", Message::std, "Memory leak: %1", "varname"));
err.push_back(Message("resourceLeak", Message::std, "Resource 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.. // checkother.cpp..
err.push_back(Message("cstyleCast", Message::style, "C-style pointer casting")); err.push_back(Message("cstyleCast", Message::style, "C-style pointer casting"));