From a1a695dcdaf2a27ab1576ca3cbc323af55e12c56 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Thu, 20 Dec 2018 21:14:02 +0100 Subject: [PATCH] checkio: Add missing id "invalidScanfFormatWidth_smaller" to errorlist output (#1533) --- lib/checkio.cpp | 2 +- lib/checkio.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/checkio.cpp b/lib/checkio.cpp index acdf2fa79..783a05f1f 100644 --- a/lib/checkio.cpp +++ b/lib/checkio.cpp @@ -1982,7 +1982,7 @@ void CheckIO::invalidScanfFormatWidthError(const Token* tok, unsigned int numFor std::ostringstream errmsg; if (arrlen > width) { - if (!mSettings->inconclusive || !mSettings->isEnabled(Settings::WARNING)) + if (tok != nullptr && (!mSettings->inconclusive || !mSettings->isEnabled(Settings::WARNING))) return; errmsg << "Width " << width << " given in format string (no. " << numFormat << ") is smaller than destination buffer" << " '" << varname << "[" << arrlen << "]'."; diff --git a/lib/checkio.h b/lib/checkio.h index dcab504a7..ad4838d6e 100644 --- a/lib/checkio.h +++ b/lib/checkio.h @@ -162,6 +162,7 @@ private: c.invalidPrintfArgTypeError_float(nullptr, 1, "f", nullptr); c.invalidLengthModifierError(nullptr, 1, "I"); c.invalidScanfFormatWidthError(nullptr, 10, 5, nullptr, 's'); + c.invalidScanfFormatWidthError(nullptr, 99, -1, nullptr, 's'); c.wrongPrintfScanfPosixParameterPositionError(nullptr, "printf", 2, 1); }