From 8226b3135c47bc609aa68b84e3309f8e6dc08964 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Fri, 27 Mar 2026 17:01:25 +0100 Subject: [PATCH 1/2] Update checkio.cpp --- lib/checkio.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/checkio.cpp b/lib/checkio.cpp index ee1b4e36c73..0e1d0395146 100644 --- a/lib/checkio.cpp +++ b/lib/checkio.cpp @@ -674,7 +674,6 @@ void CheckIO::checkFormatString(const Token * const tok, ++i; } if (scanf_s && !skip) { - numSecure++; if (argListTok) { argListTok = argListTok->nextArgument(); } @@ -722,7 +721,7 @@ void CheckIO::checkFormatString(const Token * const tok, if (!(argInfo.isArrayOrPointer() && argInfo.element && !argInfo.typeToken->isStandardType())) invalidScanfArgTypeError_s(tok, numFormat, specifier, &argInfo); } - if (scanf_s && argInfo.typeToken) { + if (scanf_s) { numSecure++; if (argListTok) { argListTok = argListTok->nextArgument(); From 08b642f5d092ccd6c15f1dc718fd3c62d6976653 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Fri, 27 Mar 2026 17:07:12 +0100 Subject: [PATCH 2/2] Update testio.cpp --- test/testio.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/testio.cpp b/test/testio.cpp index b402f5c0aa1..ec6a87a1e16 100644 --- a/test/testio.cpp +++ b/test/testio.cpp @@ -4800,6 +4800,13 @@ class TestIO : public TestFixture { " wscanf_s(L\"%4[^-]\", msStr1, _countof(msStr1));\n" "}\n", dinit(CheckOptions, $.platform = Platform::Type::Win32W)); ASSERT_EQUALS("", errout_str()); + + check("void f(const char* c) {\n" + " const size_t N = 5;\n" + " char buf[N];\n" + " sscanf_s(c, \"%4[^.]\", buf, N);\n" + "}\n", dinit(CheckOptions, $.platform = Platform::Type::Win64)); + ASSERT_EQUALS("", errout_str()); } void testQStringFormatArguments() {