[OPEN-ILS-DEV] osrf_json_xml.c: memory leak and apparent bug

Bill Erickson erickson at esilibrary.com
Tue Jan 29 12:29:06 EST 2008


Scott McKellar wrote:
> At the end of startElementHandler(), there is a branch of code that
> runs when the name passed in is "boolean".  It constructs a jsonObject
> of type JSON_BOOL but doesn't do anything with it.  The pointer goes
> out of scope and the memory leaks.
> 
> As a result, this branch of logic has no effect at all, except to
> leak memory.
> 
> I would have expected a call to appendChild(), and probably to
> osrfListPush() as well.  However the other branches are not completely
> consistent in this regard -- for "null" we create a jsonObject and
> pass it to appendChild(), but we don't call osrfListPush() for it.


Given the wait-and-see approach of SAX parsing, some data has to be
pushed onto various stacks for processing in later callbacks, hence the
inconsistencies in the code branches.

For boolean objects, we have all the data we need at element parse time,
so all that's left is call appendChild() to shove the un-used boolean
object onto the growing JSON object.

I'll go ahead and commit that fix.

Thanks for the eyes, Scott.

-bill



-- 
Bill Erickson
| VP, Software Development & Integration
| Equinox Software, Inc. / The Evergreen Experts
| phone: 877-OPEN-ILS (673-6457)
| email: erickson at esilibrary.com
| web: http://esilibrary.com


More information about the Open-ils-dev mailing list