diff --git a/src/checkmemoryleak.cpp b/src/checkmemoryleak.cpp index cc12918f8..c5ec210d1 100644 --- a/src/checkmemoryleak.cpp +++ b/src/checkmemoryleak.cpp @@ -1171,9 +1171,7 @@ void CheckMemoryLeakClass::CheckMemoryLeak_CheckScope(const Token *Tok1, const c } if ((result = Token::findmatch(tok, "dealloc [;{}] use|use_ ;")) != NULL) { - std::ostringstream errmsg; - errmsg << _tokenizer->fileLine(result->tokAt(2)) << ": Using \"" << varname << "\" after it has been deallocated / released"; - _errorLogger->reportErr(errmsg.str()); + ErrorMessage::deallocuse(_errorLogger, _tokenizer, result->tokAt(2), varname); } // Replace "&use" with "use". Replace "use_" with ";" diff --git a/test/testcppcheck.cpp b/test/testcppcheck.cpp index 602ddf876..7226fbd3d 100644 --- a/test/testcppcheck.cpp +++ b/test/testcppcheck.cpp @@ -63,7 +63,7 @@ private: check(filedata); // Compare results.. - ASSERT_EQUALS("[file.cpp:5]: Using \"foo\" after it has been deallocated / released\n", errout.str()); + ASSERT_EQUALS("[file.cpp:5]: (error) Using 'foo' after it is deallocated / released\n", errout.str()); } void linenumbers2() diff --git a/test/testmemleak.cpp b/test/testmemleak.cpp index 03f2c285d..5c2c59b75 100644 --- a/test/testmemleak.cpp +++ b/test/testmemleak.cpp @@ -1669,7 +1669,7 @@ private: " delete [] s;\n" " p = s;\n" "}\n"); - ASSERT_EQUALS(std::string("[test.cpp:5]: Using \"s\" after it has been deallocated / released\n"), errout.str()); + ASSERT_EQUALS(std::string("[test.cpp:5]: (error) Using 's' after it is deallocated / released\n"), errout.str()); } void dealloc_use_2() @@ -1714,7 +1714,7 @@ private: " free(str);\n" " char c = str[10];\n" "}\n"); - ASSERT_EQUALS(std::string("[test.cpp:5]: Using \"str\" after it has been deallocated / released\n"), errout.str()); + ASSERT_EQUALS(std::string("[test.cpp:5]: (error) Using 'str' after it is deallocated / released\n"), errout.str()); } void dealloc_use_6() @@ -1736,7 +1736,7 @@ private: " delete [] str;\n" " str[10] = 0;\n" "}\n"); - ASSERT_EQUALS(std::string("[test.cpp:5]: Using \"str\" after it has been deallocated / released\n"), errout.str()); + ASSERT_EQUALS(std::string("[test.cpp:5]: (error) Using 'str' after it is deallocated / released\n"), errout.str()); }