[Opensrf-commits] r1690 - trunk/src/libopensrf (scottmk)
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue Mar 31 14:34:52 EDT 2009
Author: scottmk
Date: 2009-03-31 14:34:48 -0400 (Tue, 31 Mar 2009)
New Revision: 1690
Modified:
trunk/src/libopensrf/osrfConfig.c
Log:
In osrfConfigGetValue(): plugged a memory leak
reported by Steven Chan.
Modified: trunk/src/libopensrf/osrfConfig.c
===================================================================
--- trunk/src/libopensrf/osrfConfig.c 2009-03-31 18:30:10 UTC (rev 1689)
+++ trunk/src/libopensrf/osrfConfig.c 2009-03-31 18:34:48 UTC (rev 1690)
@@ -76,22 +76,24 @@
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, ...) {
More information about the opensrf-commits
mailing list