From 6a03aa43151967511dfe8f99cca435078b57d8f8 Mon Sep 17 00:00:00 2001 From: scottmk Date: Tue, 31 Mar 2009 18:34:48 +0000 Subject: [PATCH] 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 --- src/libopensrf/osrfConfig.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) 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, ...) { -- 2.43.2