diff --git a/ChangeLog b/ChangeLog index 5b6909758f..5dea73e228 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +0.4 + * Fix additional error case in object parsing + * Add back sign reversal in nested object parse as error pointer + value is negative, while error value is positive. + Michael Clark + 0.3 * fix pointer arithmetic bug for error pointer check in is_error() macro * fix type passed to printbuf_memappend in json_tokener diff --git a/README.html b/README.html index 52b44953e1..65d9917efb 100644 --- a/README.html +++ b/README.html @@ -8,7 +8,7 @@

JSON-C - A JSON implementation in C

-

Latest release: json-c-0.3.tar.gz

+

Latest release: json-c-0.4.tar.gz

JSON-C implements a reference counting object model that allows you to easily construct JSON objects in C, output them as JSON formatted strings and parse JSON formatted strings back into the C representation of JSON objects.

diff --git a/json_tokener.c b/json_tokener.c index a224c7df74..fdb51135b0 100644 --- a/json_tokener.c +++ b/json_tokener.c @@ -1,5 +1,5 @@ /* - * $Id: json_tokener.c,v 1.15 2005/07/15 03:19:43 mclark Exp $ + * $Id: json_tokener.c,v 1.17 2005/07/26 07:49:11 mclark Exp $ * * Copyright Metaparadigm Pte. Ltd. 2004. * Michael Clark @@ -350,7 +350,7 @@ static struct json_object* json_tokener_do_parse(struct json_tokener *this) } else { obj = json_tokener_do_parse(this); if(is_error(obj)) { - err = (enum json_tokener_error)obj; + err = -(enum json_tokener_error)obj; goto out; } json_object_array_add(current, obj); @@ -389,6 +389,9 @@ static struct json_object* json_tokener_do_parse(struct json_tokener *this) printbuf_reset(this->pb); state = json_tokener_state_object_field; start_offset = ++this->pos; + } else { + err = json_tokener_error_parse_object; + goto out; } break; @@ -419,7 +422,7 @@ static struct json_object* json_tokener_do_parse(struct json_tokener *this) case json_tokener_state_object_value: obj = json_tokener_do_parse(this); if(is_error(obj)) { - err = (enum json_tokener_error)obj; + err = -(enum json_tokener_error)obj; goto out; } json_object_object_add(current, obj_field_name, obj); @@ -457,5 +460,5 @@ static struct json_object* json_tokener_do_parse(struct json_tokener *this) mc_debug("json_tokener_do_parse: error=%d state=%d char=%c\n", err, state, c); json_object_put(current); - return error_ptr((ptrdiff_t)-err); + return error_ptr(-err); } diff --git a/test1.c b/test1.c index 2376d4a8fe..7f34cdc67f 100644 --- a/test1.c +++ b/test1.c @@ -121,6 +121,9 @@ int main(int argc, char **argv) printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj)); json_object_put(new_obj); + new_obj = json_tokener_parse("{ foo }"); + if(is_error(new_obj)) printf("got error as expected\n"); + new_obj = json_tokener_parse("foo"); if(is_error(new_obj)) printf("got error as expected\n");