提交 c3274715 authored 作者: Michael Jerris's avatar Michael Jerris

core: fix segfault on out of memory situation. (FSCORE-366)

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@13398 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 03ba64ae
...@@ -2316,8 +2316,9 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_new(const char *name) ...@@ -2316,8 +2316,9 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_new(const char *name)
static const char *ent[] = { "lt;", "<", "gt;", ">", "quot;", """, static const char *ent[] = { "lt;", "<", "gt;", ">", "quot;", """,
"apos;", "'", "amp;", "&", NULL "apos;", "'", "amp;", "&", NULL
}; };
switch_xml_root_t root = (switch_xml_root_t) memset(malloc(sizeof(struct switch_xml_root)), switch_xml_root_t root = (switch_xml_root_t) malloc(sizeof(struct switch_xml_root));
'\0', sizeof(struct switch_xml_root)); if (!root) return NULL;
memset(root, '\0', sizeof(struct switch_xml_root));
root->xml.name = (char *) name; root->xml.name = (char *) name;
root->cur = &root->xml; root->cur = &root->xml;
strcpy(root->err, root->xml.txt = (char *)""); strcpy(root->err, root->xml.txt = (char *)"");
...@@ -2372,9 +2373,9 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_add_child(switch_xml_t xml, const char * ...@@ -2372,9 +2373,9 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_add_child(switch_xml_t xml, const char *
{ {
switch_xml_t child; switch_xml_t child;
if (!xml) if (!xml) return NULL;
return NULL; if (!(child = (switch_xml_t) malloc(sizeof(struct switch_xml)))) return NULL;
child = (switch_xml_t) memset(malloc(sizeof(struct switch_xml)), '\0', sizeof(struct switch_xml)); memset(child, '\0', sizeof(struct switch_xml));
child->name = (char *) name; child->name = (char *) name;
child->attr = SWITCH_XML_NIL; child->attr = SWITCH_XML_NIL;
child->off = off; child->off = off;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论