From: scottmk Date: Tue, 31 Mar 2009 18:34:48 +0000 (+0000) Subject: In osrfConfigGetValue(): plugged a memory leak X-Git-Tag: osrf_rel_2_0_1~386 X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=6a03aa43151967511dfe8f99cca435078b57d8f8;p=OpenSRF.git In osrfConfigGetValue(): plugged a memory leak reported by Steven Chan. git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1690 9efc2488-bf62-4759-914b-345cdb29e865 --- diff --git a/src/libopensrf/osrfConfig.c b/src/libopensrf/osrfConfig.c index 44ff14d..d90e272 100644 --- a/src/libopensrf/osrfConfig.c +++ b/src/libopensrf/osrfConfig.c @@ -76,22 +76,24 @@ char* osrfConfigGetValue(const osrfConfig* cfg, const char* path, ...) { if(!path) return NULL; if(!cfg) cfg = osrfConfigDefault; if(!cfg) { - osrfLogWarning( OSRF_LOG_MARK, "No Config object in osrfConfigGetValue()"); - return NULL; - } + osrfLogWarning( OSRF_LOG_MARK, "No Config object in osrfConfigGetValue()"); + return NULL; + } VA_LIST_TO_STRING(path); jsonObject* obj; - if(cfg->configContext) - obj = jsonObjectGetIndex( - jsonObjectFindPath(cfg->config, "//%s%s", cfg->configContext, VA_BUF), 0); - else + if(cfg->configContext) { + jsonObject* outer_obj = + jsonObjectFindPath(cfg->config, "//%s%s", cfg->configContext, VA_BUF); + obj = jsonObjectExtractIndex( outer_obj, 0 ); + jsonObjectFree( outer_obj ); + } else obj = jsonObjectFindPath( cfg->config, VA_BUF); char* val = jsonObjectToSimpleString(obj); - jsonObjectFree(obj); - return val; + jsonObjectFree(obj); + return val; } jsonObject* osrfConfigGetValueObject(osrfConfig* cfg, char* path, ...) {