fixed null pointer dereference when using --errorlist

This commit is contained in:
Daniel Marjamäki 2010-02-06 19:45:56 +01:00
parent 0a31e5e3ee
commit bdfad4eb3f
1 changed files with 2 additions and 1 deletions

View File

@ -601,5 +601,6 @@ void CheckStl::size()
void CheckStl::sizeError(const Token *tok) void CheckStl::sizeError(const Token *tok)
{ {
const std::string varname(tok ? tok->str().c_str() : "list"); 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." : ""));
} }