From: scottmk Date: Thu, 19 Feb 2009 16:07:39 +0000 (+0000) Subject: In searchJOIN(): avoided a segfault that would otherwise happen X-Git-Tag: sprint4-merge-nov22~10769 X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=13f63e69b8d544e241dc20976276843c6c0f0b5e;p=working%2FEvergreen.git In searchJOIN(): avoided a segfault that would otherwise happen if the JSON query tried to join to a class not defined in the IDL. git-svn-id: svn://svn.open-ils.org/ILS/trunk@12233 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/c-apps/oils_cstore.c b/Open-ILS/src/c-apps/oils_cstore.c index 59559fa28b..d0674cb7ca 100644 --- a/Open-ILS/src/c-apps/oils_cstore.c +++ b/Open-ILS/src/c-apps/oils_cstore.c @@ -2028,9 +2028,22 @@ static char* searchJOIN ( const jsonObject* join_hash, osrfHash* leftmeta ) { 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 @@ static char* searchJOIN ( const jsonObject* join_hash, osrfHash* leftmeta ) { } } osrfHashIteratorFree( itr ); - + if (!field || !fkey) { // Do another such search, with the classes reversed _links = oilsIDLFindPath("/%s/links", class); @@ -2664,7 +2677,7 @@ char* SELECT ( // 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); }