[Opensrf-commits] r1268 - trunk/src/libopensrf

svn at svn.open-ils.org svn at svn.open-ils.org
Sun Mar 9 22:54:03 EDT 2008


Author: miker
Date: 2008-03-09 22:21:03 -0400 (Sun, 09 Mar 2008)
New Revision: 1268

Modified:
   trunk/src/libopensrf/osrf_json_parser.c
Log:
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().



Modified: trunk/src/libopensrf/osrf_json_parser.c
===================================================================
--- trunk/src/libopensrf/osrf_json_parser.c	2008-03-10 01:14:03 UTC (rev 1267)
+++ trunk/src/libopensrf/osrf_json_parser.c	2008-03-10 02:21:03 UTC (rev 1268)
@@ -678,11 +678,10 @@
 	} 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 )



More information about the opensrf-commits mailing list