From bba57cc4af7f52f2d880842e0020b1d6e2af35f5 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Thu, 23 Jul 2020 14:02:49 +0200 Subject: [PATCH] :rotating_light: fix UBSAN warning --- test/src/unit-regression.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/src/unit-regression.cpp b/test/src/unit-regression.cpp index 649ac656..d70114ee 100644 --- a/test/src/unit-regression.cpp +++ b/test/src/unit-regression.cpp @@ -1516,8 +1516,8 @@ TEST_CASE("regression tests") SECTION("issue #838 - incorrect parse error with binary data in keys") { - uint8_t key1[] = { 103, 92, 117, 48, 48, 48, 55, 92, 114, 215, 126, 214, 95, 92, 34, 174, 40, 71, 38, 174, 40, 71, 38, 223, 134, 247, 127 }; - std::string key1_str(key1, key1 + sizeof(key1) / sizeof(key1[0])); + uint8_t key1[] = { 103, 92, 117, 48, 48, 48, 55, 92, 114, 215, 126, 214, 95, 92, 34, 174, 40, 71, 38, 174, 40, 71, 38, 223, 134, 247, 127, 0 }; + std::string key1_str(reinterpret_cast(key1)); json j = key1_str; CHECK_THROWS_AS(j.dump(), json::type_error&); CHECK_THROWS_WITH(j.dump(), "[json.exception.type_error.316] invalid UTF-8 byte at index 10: 0x7E");