From 59cb4c93be2671026a41e71cd11cc1bd2a794f41 Mon Sep 17 00:00:00 2001 From: chenguoping Date: Mon, 23 Mar 2020 16:08:47 +0800 Subject: [PATCH] fix C26451 warnning in serializer.hpp for VS2019 --- include/nlohmann/detail/output/serializer.hpp | 4 +++- single_include/nlohmann/json.hpp | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/include/nlohmann/detail/output/serializer.hpp b/include/nlohmann/detail/output/serializer.hpp index 0a4ddbda..c6f217cb 100644 --- a/include/nlohmann/detail/output/serializer.hpp +++ b/include/nlohmann/detail/output/serializer.hpp @@ -807,7 +807,9 @@ class serializer ? (byte & 0x3fu) | (codep << 6u) : (0xFFu >> type) & (byte); - state = utf8d[256u + state * 16u + type]; + std::size_t index = 256u + static_cast(state) * 16u + static_cast(type); + assert(0 <= index and index < 400); + state = utf8d[index]; return state; } diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 68916fa0..8089e9fa 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -14552,7 +14552,9 @@ class serializer ? (byte & 0x3fu) | (codep << 6u) : (0xFFu >> type) & (byte); - state = utf8d[256u + state * 16u + type]; + std::size_t index = 256u + static_cast(state) * 16u + static_cast(type); + assert(0 <= index and index < 400); + state = utf8d[index]; return state; }