[open-ils-commits] r12054 - trunk/Open-ILS/src/c-apps

svn at svn.open-ils.org svn at svn.open-ils.org
Tue Feb 3 20:43:26 EST 2009


Author: scottmk
Date: 2009-02-03 20:43:25 -0500 (Tue, 03 Feb 2009)
New Revision: 12054

Modified:
   trunk/Open-ILS/src/c-apps/oils_cstore.c
Log:
This update tweaks the SELECT function, at the point commented
"make sure the target relation is in the join tree".

The new logic should be equivalent to the old, except that
the old code potentially invokes undefined behavior by
reading through a null pointer.


Modified: trunk/Open-ILS/src/c-apps/oils_cstore.c
===================================================================
--- trunk/Open-ILS/src/c-apps/oils_cstore.c	2009-02-03 22:44:48 UTC (rev 12053)
+++ trunk/Open-ILS/src/c-apps/oils_cstore.c	2009-02-04 01:43:25 UTC (rev 12054)
@@ -2326,7 +2326,6 @@
 	jsonObject* selfield = NULL;
 	jsonObject* snode = NULL;
 	jsonObject* onode = NULL;
-	jsonObject* found = NULL;
 
 	char* string = NULL;
 	int from_function = 0;
@@ -2439,20 +2438,20 @@
 		    if (strcmp(core_class,cname)) {
 			    if (!join_hash) continue;
 
-			    if (join_hash->type == JSON_STRING) {
+				unsigned long size;
+
+				if (join_hash->type == JSON_STRING) {
 				    string = jsonObjectToSimpleString(join_hash);
-				    found = strcmp(string,cname) ? NULL : jsonParseString("{\"1\":\"1\"}");
+					size = strcmp( string, cname ) ? 0 : 1;
 				    free(string);
 			    } else {
-				    found = jsonObjectFindPath(join_hash, "//%s", cname);
+				    jsonObject* found = jsonObjectFindPath(join_hash, "//%s", cname);
+					size = found->size;
+					jsonObjectFree( found );
 			    }
 
-			    if (!found->size) {
-				    jsonObjectFree(found);
+			    if ( 0 == size )
 				    continue;
-			    }
-
-			    jsonObjectFree(found);
 		    }
 
 		    // stitch together the column list ...



More information about the open-ils-commits mailing list