Fixed #2292 (segmentation fault with cppcheck 1.46 with --errorlist)

This commit is contained in:
Daniel Marjamäki 2010-12-13 18:17:33 +01:00
parent 7d1b2254d3
commit 5ce63a1df0
2 changed files with 11 additions and 2 deletions

View File

@ -114,7 +114,7 @@ void CheckBufferOverrun::bufferOverrun(const Token *tok, const std::string &varn
void CheckBufferOverrun::strncatUsage(const Token *tok)
{
if (!_settings->_checkCodingStyle)
if (_settings && !_settings->_checkCodingStyle)
return;
reportError(tok, Severity::warning, "strncatUsage", "Dangerous usage of strncat. Tip: the 3rd parameter means maximum number of characters to append");
@ -127,7 +127,7 @@ void CheckBufferOverrun::outOfBounds(const Token *tok, const std::string &what)
void CheckBufferOverrun::sizeArgumentAsChar(const Token *tok)
{
if (!_settings->_checkCodingStyle)
if (_settings && !_settings->_checkCodingStyle)
return;
reportError(tok, Severity::warning, "sizeArgumentAsChar", "The size argument is given as a char constant");
}

View File

@ -188,6 +188,8 @@ private:
TEST_CASE(cmdLineArgs1);
TEST_CASE(scope); // handling different scopes
TEST_CASE(getErrorMessages);
}
@ -2699,6 +2701,13 @@ private:
"}\n");
ASSERT_EQUALS("", errout.str());
}
void getErrorMessages()
{
// Ticket #2292: segmentation fault when using --errorlist
CheckBufferOverrun c;
c.getErrorMessages();
}
};
REGISTER_TEST(TestBufferOverrun)