Fixed #2292 (segmentation fault with cppcheck 1.46 with --errorlist)
This commit is contained in:
parent
7d1b2254d3
commit
5ce63a1df0
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue