[Freeswitch-svn] [commit] r5699 - freeswitch/trunk/src/mod/xml_int/mod_xml_rpc
Freeswitch SVN
mikej at freeswitch.org
Tue Sep 11 18:29:30 EDT 2007
Author: mikej
Date: Tue Sep 11 18:29:29 2007
New Revision: 5699
Modified:
freeswitch/trunk/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c
Log:
Fix for memory leak in xml-rpc (MDXMLINT-10) from Bret McDanel.
Modified: freeswitch/trunk/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c
==============================================================================
--- freeswitch/trunk/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c (original)
+++ freeswitch/trunk/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c Tue Sep 11 18:29:29 2007
@@ -272,7 +272,7 @@
static xmlrpc_value *freeswitch_api(xmlrpc_env * const envP, xmlrpc_value * const paramArrayP, void *const userData)
{
- char *command, *arg;
+ char *command = NULL, *arg = NULL;
switch_stream_handle_t stream = { 0 };
xmlrpc_value *val = NULL;
@@ -280,7 +280,7 @@
/* Parse our argument array. */
xmlrpc_decompose_value(envP, paramArrayP, "(ss)", &command, &arg);
if (envP->fault_occurred) {
- return NULL;
+ goto done;
}
SWITCH_STANDARD_STREAM(stream);
@@ -292,20 +292,24 @@
val = xmlrpc_build_value(envP, "s", "ERROR!");
}
+done:
+ /* xmlrpc-c requires us to free memory it malloced from xmlrpc_decompose_value */
+ switch_safe_free(command);
+ switch_safe_free(arg);
return val;
}
static xmlrpc_value *freeswitch_man(xmlrpc_env * const envP, xmlrpc_value * const paramArrayP, void *const userData)
{
- char *oid, *relative_oid, *s_action, *data;
+ char *oid = NULL, *relative_oid, *s_action = NULL, *data = NULL;
char buf[SWITCH_MAX_MANAGEMENT_BUFFER_LEN] = "";
switch_management_action_t action = SMA_NONE;
- xmlrpc_value *val;
+ xmlrpc_value *val = NULL;
/* Parse our argument array. */
xmlrpc_decompose_value(envP, paramArrayP, "(sss)", &oid, &s_action, &data);
if (envP->fault_occurred) {
- return NULL;
+ goto done;
}
if (!strncasecmp(oid, FREESWITCH_OID_PREFIX, strlen(FREESWITCH_OID_PREFIX))) {
@@ -343,7 +347,11 @@
/* Return our result. */
val = xmlrpc_build_value(envP, "s", buf);
-
+done:
+ /* xmlrpc-c requires us to free memory it malloced from xmlrpc_decompose_value */
+ switch_safe_free(oid);
+ switch_safe_free(s_action);
+ switch_safe_free(data);
return val;
}
More information about the Freeswitch-svn
mailing list