From 55ff4c9effa76e3895f9ffe8a7f68c4e0b0b08c8 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Tue, 15 Sep 2026 10:22:47 +0000 Subject: [PATCH] test: drop a trailing NUL byte from the nativejson-benchmark 1e308 fixture The "doubles" compliance test built its 1e308 literal as a std::string sized to 312 bytes with an explicit trailing '\0' at index 311, relying on the old NUL-as-EOF lexer behavior removed earlier in this branch: with that removed, the NUL is ordinary (invalid) trailing data instead of being silently swallowed, so json::parse() correctly rejected it with parse_error.101 - breaking CI across every compiler/platform, since this one nativejson-benchmark TEST_CASE is exercised by every test job. No padding is needed at all: json::parse(const std::string&) already uses the string's own size(), not a NUL terminator. Drop the trailing byte and shrink the string by one to match (index 310 - the new last index - is where ']' now goes), fixing this the same way the other pre-existing tests in this branch that depended on the same bug were already fixed. Signed-off-by: Niels Lohmann Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01N4RQ1Ahan5YAGbnAQGjZTY --- tests/src/unit-testsuites.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/src/unit-testsuites.cpp b/tests/src/unit-testsuites.cpp index 672981967..c7b43c2e5 100644 --- a/tests/src/unit-testsuites.cpp +++ b/tests/src/unit-testsuites.cpp @@ -214,11 +214,13 @@ TEST_CASE("compliance tests from nativejson-benchmark") 5708990770823839524233143877797980545530986496.0); { - std::string n1e308(312, '0'); // '1' followed by 308 '0' + // note: no trailing NUL byte - a NUL is ordinary (invalid) data + // now, not end-of-input, so it is no longer needed (or valid) + // padding here; see issue #5530 + std::string n1e308(311, '0'); // '1' followed by 308 '0' n1e308[0] = '['; n1e308[1] = '1'; n1e308[310] = ']'; - n1e308[311] = '\0'; TEST_DOUBLE(n1e308, 1E308); }