From f9f8c077923490c95188d35dd3f43be962809efd Mon Sep 17 00:00:00 2001 From: Stuart Gorman <32289199+StuartGorman@users.noreply.github.com> Date: Thu, 21 Nov 2024 22:09:29 +1000 Subject: [PATCH] fix: integer parsed as float when EINTR set in errno (#4506) * fix: integer parsed as float when EINTR set in errno * chore: make amalgamate * chore: make pretty --------- Co-authored-by: Stuart Gorman --- include/nlohmann/detail/input/lexer.hpp | 4 ++-- single_include/nlohmann/json.hpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/nlohmann/detail/input/lexer.hpp b/include/nlohmann/detail/input/lexer.hpp index 059a08073..a2a04fff7 100644 --- a/include/nlohmann/detail/input/lexer.hpp +++ b/include/nlohmann/detail/input/lexer.hpp @@ -1256,7 +1256,7 @@ scan_number_done: // we checked the number format before JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size()); - if (errno == 0) + if (errno != ERANGE) { value_unsigned = static_cast(x); if (value_unsigned == x) @@ -1272,7 +1272,7 @@ scan_number_done: // we checked the number format before JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size()); - if (errno == 0) + if (errno != ERANGE) { value_integer = static_cast(x); if (value_integer == x) diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index e7e8fe743..6fe8a5de2 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -8725,7 +8725,7 @@ scan_number_done: // we checked the number format before JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size()); - if (errno == 0) + if (errno != ERANGE) { value_unsigned = static_cast(x); if (value_unsigned == x) @@ -8741,7 +8741,7 @@ scan_number_done: // we checked the number format before JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size()); - if (errno == 0) + if (errno != ERANGE) { value_integer = static_cast(x); if (value_integer == x)