mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-02-04 18:27:36 +00:00
Fix leak-on-failure
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@13260 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
06babac1e4
commit
5802cb943a
@ -905,12 +905,18 @@ static void switch_xml_free_attr(char **attr)
|
|||||||
SWITCH_DECLARE(switch_xml_t) switch_xml_parse_str_dynamic(char *s, switch_bool_t dup)
|
SWITCH_DECLARE(switch_xml_t) switch_xml_parse_str_dynamic(char *s, switch_bool_t dup)
|
||||||
{
|
{
|
||||||
switch_xml_root_t root;
|
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)))) {
|
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() */
|
root->dynamic = 1; /* Make sure we free the memory is switch_xml_free() */
|
||||||
return &root->xml;
|
return &root->xml;
|
||||||
} else {
|
} else {
|
||||||
|
if (dup) {
|
||||||
|
free(data);
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user