Skip to content

Commit a1a695d

Browse files
versatamai2012
authored andcommitted
checkio: Add missing id "invalidScanfFormatWidth_smaller" to errorlist output (danmar#1533)
1 parent d528934 commit a1a695d

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

lib/checkio.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1982,7 +1982,7 @@ void CheckIO::invalidScanfFormatWidthError(const Token* tok, unsigned int numFor
19821982

19831983
std::ostringstream errmsg;
19841984
if (arrlen > width) {
1985-
if (!mSettings->inconclusive || !mSettings->isEnabled(Settings::WARNING))
1985+
if (tok != nullptr && (!mSettings->inconclusive || !mSettings->isEnabled(Settings::WARNING)))
19861986
return;
19871987
errmsg << "Width " << width << " given in format string (no. " << numFormat << ") is smaller than destination buffer"
19881988
<< " '" << varname << "[" << arrlen << "]'.";

lib/checkio.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ class CPPCHECKLIB CheckIO : public Check {
162162
c.invalidPrintfArgTypeError_float(nullptr, 1, "f", nullptr);
163163
c.invalidLengthModifierError(nullptr, 1, "I");
164164
c.invalidScanfFormatWidthError(nullptr, 10, 5, nullptr, 's');
165+
c.invalidScanfFormatWidthError(nullptr, 99, -1, nullptr, 's');
165166
c.wrongPrintfScanfPosixParameterPositionError(nullptr, "printf", 2, 1);
166167
}
167168

0 commit comments

Comments
 (0)