diff --git a/src/checkmemoryleak.cpp b/src/checkmemoryleak.cpp index ef1e458d2..ad9f5c4ad 100644 --- a/src/checkmemoryleak.cpp +++ b/src/checkmemoryleak.cpp @@ -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") && diff --git a/src/errormessage.h b/src/errormessage.h index eccd12032..7e2530833 100644 --- a/src/errormessage.h +++ b/src/errormessage.h @@ -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) { diff --git a/test/testmemleak.cpp b/test/testmemleak.cpp index 9adbc2e85..a11db3e62 100644 --- a/test/testmemleak.cpp +++ b/test/testmemleak.cpp @@ -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() diff --git a/tools/errmsg.cpp b/tools/errmsg.cpp index eccb7d59e..2441454c7 100644 --- a/tools/errmsg.cpp +++ b/tools/errmsg.cpp @@ -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"));