[Freeswitch-svn] [commit] r13260 - freeswitch/trunk/src
FreeSWITCH SVN
mrene at freeswitch.org
Thu May 7 21:33:58 PDT 2009
Author: mrene
Date: Thu May 7 23:33:58 2009
New Revision: 13260
Log:
Fix leak-on-failure
Modified:
freeswitch/trunk/src/switch_xml.c
Modified: freeswitch/trunk/src/switch_xml.c
==============================================================================
--- freeswitch/trunk/src/switch_xml.c (original)
+++ freeswitch/trunk/src/switch_xml.c Thu May 7 23:33:58 2009
@@ -905,12 +905,18 @@
SWITCH_DECLARE(switch_xml_t) switch_xml_parse_str_dynamic(char *s, switch_bool_t dup)
{
switch_xml_root_t root;
- char *data = dup ? strdup(s) : s;
+ char *data;
+
+ switch_assert(s);
+ data = dup ? strdup(s) : s;
if ((root = (switch_xml_root_t) switch_xml_parse_str(data, strlen(data)))) {
root->dynamic = 1; /* Make sure we free the memory is switch_xml_free() */
return &root->xml;
} else {
+ if (dup) {
+ free(data);
+ }
return NULL;
}
}
More information about the Freeswitch-svn
mailing list