From bdfad4eb3f5c0bc83ac3cf70a1044d793fe8c96d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 6 Feb 2010 19:45:56 +0100 Subject: [PATCH] fixed null pointer dereference when using --errorlist --- lib/checkstl.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/checkstl.cpp b/lib/checkstl.cpp index 7f39a6c50..08960bc6b 100644 --- a/lib/checkstl.cpp +++ b/lib/checkstl.cpp @@ -601,5 +601,6 @@ void CheckStl::size() void CheckStl::sizeError(const Token *tok) { const std::string varname(tok ? tok->str().c_str() : "list"); - reportError(tok, Severity::possibleStyle, "stlSize", "Use " + varname + ".empty() instead of " + varname + ".size() to guarantee fast code." + (_settings->_verbose ? " size() can take linear time but empty() is guaranteed to take constant time." : "")); + const bool verbose(_settings ? _settings->_verbose : true); + reportError(tok, Severity::possibleStyle, "stlSize", "Use " + varname + ".empty() instead of " + varname + ".size() to guarantee fast code." + (verbose ? " size() can take linear time but empty() is guaranteed to take constant time." : "")); }