From 4d1e0b44099c85b118f6cdb2c7b116fd92e6f2a4 Mon Sep 17 00:00:00 2001 From: Eric Haszlakiewicz Date: Sun, 26 Nov 2017 22:42:40 -0500 Subject: [PATCH] Issue #371: fix parsing of "-Infinity" (although in a somewhat different location than PR#372 used), and add a case to test_parse to check for this. --- json_tokener.c | 1 + tests/test_parse.c | 1 + tests/test_parse.expected | 1 + 3 files changed, 3 insertions(+) diff --git a/json_tokener.c b/json_tokener.c index 57d8367..2a92456 100644 --- a/json_tokener.c +++ b/json_tokener.c @@ -767,6 +767,7 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok, (c == 'i' || c == 'I')) { state = json_tokener_state_inf; + tok->st_pos = 0; goto redo_char; } } diff --git a/tests/test_parse.c b/tests/test_parse.c index 0d71a47..aa02251 100644 --- a/tests/test_parse.c +++ b/tests/test_parse.c @@ -57,6 +57,7 @@ static void test_basic_parse() single_basic_parse("infinity", 0); single_basic_parse("-Infinity", 0); single_basic_parse("-infinity", 0); + single_basic_parse("{ \"min\": Infinity, \"max\": -Infinity}", 0); single_basic_parse("Infinity!", 0); single_basic_parse("Infinitynull", 0); diff --git a/tests/test_parse.expected b/tests/test_parse.expected index cc13cf3..1630998 100644 --- a/tests/test_parse.expected +++ b/tests/test_parse.expected @@ -14,6 +14,7 @@ new_obj.to_string(Infinity)=Infinity new_obj.to_string(infinity)=Infinity new_obj.to_string(-Infinity)=-Infinity new_obj.to_string(-infinity)=-Infinity +new_obj.to_string({ "min": Infinity, "max": -Infinity})={ "min": Infinity, "max": -Infinity } new_obj.to_string(Infinity!)=Infinity new_obj.to_string(Infinitynull)=Infinity new_obj.to_string(InfinityXXXX)=Infinity -- 2.50.0