Skip to content

Commit 6d25ed0

Browse files
StuartGormanStuart Gorman
authored andcommitted
fix: integer parsed as float when EINTR set in errno (nlohmann#4506)
* fix: integer parsed as float when EINTR set in errno * chore: make amalgamate * chore: make pretty --------- Co-authored-by: Stuart Gorman <[email protected]>
1 parent d9a5007 commit 6d25ed0

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

include/nlohmann/detail/input/lexer.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,7 +1256,7 @@ class lexer : public lexer_base<BasicJsonType>
12561256
// we checked the number format before
12571257
JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
12581258

1259-
if (errno == 0)
1259+
if (errno != ERANGE)
12601260
{
12611261
value_unsigned = static_cast<number_unsigned_t>(x);
12621262
if (value_unsigned == x)
@@ -1272,7 +1272,7 @@ class lexer : public lexer_base<BasicJsonType>
12721272
// we checked the number format before
12731273
JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
12741274

1275-
if (errno == 0)
1275+
if (errno != ERANGE)
12761276
{
12771277
value_integer = static_cast<number_integer_t>(x);
12781278
if (value_integer == x)

single_include/nlohmann/json.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8725,7 +8725,7 @@ class lexer : public lexer_base<BasicJsonType>
87258725
// we checked the number format before
87268726
JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
87278727

8728-
if (errno == 0)
8728+
if (errno != ERANGE)
87298729
{
87308730
value_unsigned = static_cast<number_unsigned_t>(x);
87318731
if (value_unsigned == x)
@@ -8741,7 +8741,7 @@ class lexer : public lexer_base<BasicJsonType>
87418741
// we checked the number format before
87428742
JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
87438743

8744-
if (errno == 0)
8744+
if (errno != ERANGE)
87458745
{
87468746
value_integer = static_cast<number_integer_t>(x);
87478747
if (value_integer == x)

0 commit comments

Comments
 (0)