[open-ils-commits] r12233 - trunk/Open-ILS/src/c-apps (scottmk)

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Feb 19 11:07:41 EST 2009


Author: scottmk
Date: 2009-02-19 11:07:39 -0500 (Thu, 19 Feb 2009)
New Revision: 12233

Modified:
   trunk/Open-ILS/src/c-apps/oils_cstore.c
Log:
In searchJOIN(): avoided a segfault that would otherwise happen
if the JSON query tried to join to a class not defined in the IDL.


Modified: trunk/Open-ILS/src/c-apps/oils_cstore.c
===================================================================
--- trunk/Open-ILS/src/c-apps/oils_cstore.c	2009-02-19 15:33:59 UTC (rev 12232)
+++ trunk/Open-ILS/src/c-apps/oils_cstore.c	2009-02-19 16:07:39 UTC (rev 12233)
@@ -2028,9 +2028,22 @@
 
 	jsonObject* snode = NULL;
 	jsonIterator* search_itr = jsonNewIterator( working_hash );
-	
+
 	while ( (snode = jsonIteratorNext( search_itr )) ) {
 		osrfHash* idlClass = osrfHashGet( oilsIDL(), search_itr->key );
+		if( !idlClass ) {
+			osrfLogError(
+				OSRF_LOG_MARK,
+				"%s: JOIN failed.  No class \"%s\" defined in IDL",
+				MODULENAME,
+				search_itr->key
+			);
+			jsonIteratorFree( search_itr );
+			buffer_free( join_buf );
+			if( freeable_hash )
+				jsonObjectFree( freeable_hash );
+			return NULL;
+		}
 
 		const char* class = osrfHashGet(idlClass, "classname");
 
@@ -2096,7 +2109,7 @@
 				}
 			}
 			osrfHashIteratorFree( itr );
-			
+
 			if (!field || !fkey) {
 				// Do another such search, with the classes reversed
 				_links = oilsIDLFindPath("/%s/links", class);
@@ -2664,7 +2677,7 @@
 	    // Now, walk the join tree and add that clause
 	    if ( join_hash ) {
 		    char* join_clause = searchJOIN( join_hash, core_meta );
-		    buffer_add(sql_buf, join_clause);
+			buffer_add(sql_buf, join_clause);
 		    free(join_clause);
 	    }
 



More information about the open-ils-commits mailing list