From 0e1d83f980288ab9bda6b316c0d6df6b28a0688a Mon Sep 17 00:00:00 2001 From: Eric Haszlakiewicz Date: Sun, 26 Nov 2017 23:31:00 -0500 Subject: [PATCH] Adjust the "-Infinity" fix on the json-c-0.12 branch to match the master branch. --- json_tokener.c | 2 +- tests/test_parse.c | 4 ++++ tests/test_parse.expected | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/json_tokener.c b/json_tokener.c index 0d38fc1..b57c303 100644 --- a/json_tokener.c +++ b/json_tokener.c @@ -337,7 +337,6 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok, state = json_tokener_state_number; printbuf_reset(tok->pb); tok->is_double = 0; - tok->st_pos = 0; goto redo_char; default: tok->err = json_tokener_error_parse_unexpected; @@ -686,6 +685,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 f6b5c03..5cfa6bb 100644 --- a/tests/test_parse.c +++ b/tests/test_parse.c @@ -79,6 +79,10 @@ static void test_basic_parse() printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj)); json_object_put(new_obj); + new_obj = json_tokener_parse("{ \"min\": Infinity, \"max\": -Infinity}"); + printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj)); + json_object_put(new_obj); + new_obj = json_tokener_parse("True"); printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj)); json_object_put(new_obj); diff --git a/tests/test_parse.expected b/tests/test_parse.expected index b8badda..e8a87d7 100644 --- a/tests/test_parse.expected +++ b/tests/test_parse.expected @@ -11,6 +11,7 @@ new_obj.to_string()=Infinity new_obj.to_string()=Infinity new_obj.to_string()=-Infinity new_obj.to_string()=-Infinity +new_obj.to_string()={ "min": Infinity, "max": -Infinity } new_obj.to_string()=true new_obj.to_string()=12 new_obj.to_string()=12.3