From 74b0270a0b3712e3f1f809d1cdfd5cede67a67ee Mon Sep 17 00:00:00 2001 From: miker Date: Mon, 7 Jan 2008 02:00:25 +0000 Subject: [PATCH] Memory leak fixes for the old-style gateway: 1. osrf_locale, allocated by either buffer_release() or strdup(). 2. A series of buffers allocated by apacheGetFirstParamValue(): param_locale service method format input_format a_l tout git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1207 9efc2488-bf62-4759-914b-345cdb29e865 --- src/gateway/osrf_json_gateway.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/gateway/osrf_json_gateway.c b/src/gateway/osrf_json_gateway.c index cab78fa..6eb7ab1 100644 --- a/src/gateway/osrf_json_gateway.c +++ b/src/gateway/osrf_json_gateway.c @@ -172,9 +172,9 @@ static int osrf_json_gateway_method_handler (request_rec *r) { mparams = apacheGetParamValues( params, "param" ); /* free me */ if(format == NULL) - format = "json"; + format = strdup( "json" ); if(input_format == NULL) - input_format = format; + input_format = strdup( format ); /* set the user defined timeout value */ int timeout = 60; @@ -182,10 +182,13 @@ static int osrf_json_gateway_method_handler (request_rec *r) { if( tout ) { timeout = atoi(tout); osrfLogDebug(OSRF_LOG_MARK, "Client supplied timeout of %d", timeout); + free( tout ); } - if (a_l) + if (a_l) { api_level = atoi(a_l); + free( a_l ); + } if (!strcasecmp(format, "xml")) { isXML = 1; @@ -194,6 +197,7 @@ static int osrf_json_gateway_method_handler (request_rec *r) { ap_set_content_type(r, "text/plain"); } + free( format ); int ret = OK; /* ----------------------------------------------------------------- */ @@ -285,7 +289,7 @@ static int osrf_json_gateway_method_handler (request_rec *r) { if( req_id == -1 ) { - osrfLogError(OSRF_LOG_MARK, "I am unable to communcate with opensrf..going away..."); + osrfLogError(OSRF_LOG_MARK, "I am unable to communicate with opensrf..going away..."); /* we don't want to spawn an intense re-forking storm * if there is no jabber server.. so give it some time before we die */ usleep( 100000 ); /* 100 milliseconds */ @@ -417,6 +421,10 @@ static int osrf_json_gateway_method_handler (request_rec *r) { osrfLogInfo(OSRF_LOG_MARK, "Completed processing service=%s, method=%s", service, method); string_array_destroy(params); string_array_destroy(mparams); + free( osrf_locale ); + free( input_format ); + free( method ); + free( service ); osrfLogDebug(OSRF_LOG_MARK, "Gateway served %d requests", ++numserved); osrfLogClearXid(); -- 2.43.2