提交 09e842f8 authored 作者: Michael Jerris's avatar Michael Jerris

handle some error cases.

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6881 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 724e88ad
...@@ -431,9 +431,21 @@ static void switch_xml_char_content(switch_xml_root_t root, char *s, switch_size ...@@ -431,9 +431,21 @@ static void switch_xml_char_content(switch_xml_root_t root, char *s, switch_size
if (!*(xml->txt)) if (!*(xml->txt))
xml->txt = s; // initial character content xml->txt = s; // initial character content
else { // allocate our own memory and make a copy else { // allocate our own memory and make a copy
xml->txt = (xml->flags & SWITCH_XML_TXTM) // allocate some space if ((xml->flags & SWITCH_XML_TXTM)) { // allocate some space
? (char *)realloc(xml->txt, (l = strlen(xml->txt)) + len) char *tmp = (char *)realloc(xml->txt, (l = strlen(xml->txt)) + len);
: strcpy((char *)malloc((l = strlen(xml->txt)) + len), xml->txt); if (tmp) {
xml->txt = tmp;
} else {
return;
}
} else {
char *tmp = (char *)malloc((l = strlen(xml->txt)) + len);
if (tmp) {
xml->txt = strcpy(tmp, xml->txt);
} else {
return;
}
}
strcpy(xml->txt + l, s); // add new char content strcpy(xml->txt + l, s); // add new char content
if (s != m) if (s != m)
free(s); // free s if it was malloced by switch_xml_decode() free(s); // free s if it was malloced by switch_xml_decode()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论