From: scottmk Date: Wed, 4 Feb 2009 01:43:25 +0000 (+0000) Subject: This update tweaks the SELECT function, at the point commented X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=d51cb554c8704f67beafe572e5c8b2b80f892ff3;p=evergreen%2Ftadl.git 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. git-svn-id: svn://svn.open-ils.org/ILS/trunk@12054 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 13a455a688..1b5789c292 100644 --- a/Open-ILS/src/c-apps/oils_cstore.c +++ b/Open-ILS/src/c-apps/oils_cstore.c @@ -2326,7 +2326,6 @@ static char* SELECT ( jsonObject* selfield = NULL; jsonObject* snode = NULL; jsonObject* onode = NULL; - jsonObject* found = NULL; char* string = NULL; int from_function = 0; @@ -2439,20 +2438,20 @@ static char* SELECT ( 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 ...