From 4037f82ee5ffbba7220b75c9b8d68a16ce3efd9d Mon Sep 17 00:00:00 2001 From: miker Date: Mon, 10 Mar 2008 02:21:03 +0000 Subject: [PATCH] Patch from Scott McKellar: In _jsonInsertParserItem() I changed a switch/case to an if/else, eliminating a supposedly unreachable default branch that, if reached, would leak memory. With this change, a jsonObject that is neither a JSON_HASH nor a JSON_ARRAY will be silently converted to a JSON_ARRAY by the call to jsonObjectPush(). git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1268 9efc2488-bf62-4759-914b-345cdb29e865 --- src/libopensrf/osrf_json_parser.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/libopensrf/osrf_json_parser.c b/src/libopensrf/osrf_json_parser.c index 8cb84af..fb6e61d 100644 --- a/src/libopensrf/osrf_json_parser.c +++ b/src/libopensrf/osrf_json_parser.c @@ -678,11 +678,10 @@ void _jsonInsertParserItem( jsonInternalParser* p, jsonObject* newo ) { } else { /* insert the new object into the current container object */ - switch(p->current->type) { - case JSON_HASH : jsonObjectSetKey(p->current, p->lastkey, newo); break; - case JSON_ARRAY: jsonObjectPush(p->current, newo); break; - default: fprintf(stderr, "%s:%d -> how?\n", JSON_LOG_MARK); - } + if(p->current->type == JSON_HASH) + jsonObjectSetKey(p->current, p->lastkey, newo); + else // assume it's a JSON_ARRAY; if it isn't, it'll become one + jsonObjectPush(p->current, newo); /* if the new object is a container object, make it our current container */ if( newo->type == JSON_ARRAY || newo->type == JSON_HASH ) -- 2.43.2