Modified: freeswitch/trunk/src/switch_xml.c (17407 => 17408)
--- freeswitch/trunk/src/switch_xml.c 2010-04-26 10:58:36 UTC (rev 17407)
+++ freeswitch/trunk/src/switch_xml.c 2010-04-26 11:02:26 UTC (rev 17408)
@@ -403,6 +403,10 @@
return NULL;
}
+ if (!root->attr) {
+ return NULL;
+ }
+
for (i = 0; root->attr[i] && xml->name && strcmp(xml->name, root->attr[i][0]); i++);
if (!root->attr[i])
return NULL; /* no matching default attributes */
@@ -451,6 +455,9 @@
return (const char **) SWITCH_XML_NIL;
while (root->xml.parent)
root = (switch_xml_root_t) root->xml.parent; /* root tag */
+ if (!root || !root->pi) {
+ return (const char **) SWITCH_XML_NIL;
+ }
while (root->pi[i] && strcmp(target, root->pi[i][0]))
i++; /* find target */
return (const char **) ((root->pi[i]) ? root->pi[i] + 1 : SWITCH_XML_NIL);
@@ -463,6 +470,10 @@
int line = 1;
char *t, fmt[SWITCH_XML_ERRL];
+ if (!root || !root->s) {
+ return NULL;
+ }
+
for (t = root->s; t && t < s; t++)
if (*t == '\n')
line++;
@@ -578,8 +589,14 @@
/* called when parser finds start of new tag */
static void switch_xml_open_tag(switch_xml_root_t root, char *name, char **attr)
{
- switch_xml_t xml = root->cur;
+ switch_xml_t xml;
+ if (!root || !root->cur) {
+ return;
+ }
+
+ xml = root->cur;
+
if (xml->name)
xml = switch_xml_add_child(xml, name, strlen(xml->txt));
else
@@ -592,10 +609,16 @@
/* called when parser finds character content between open and closing tag */
static void switch_xml_char_content(switch_xml_root_t root, char *s, switch_size_t len, char t)
{
- switch_xml_t xml = root->cur;
+ switch_xml_t xml;
char *m = s;
switch_size_t l;
+ if (!root || !root->cur) {
+ return;
+ }
+
+ xml = root->cur;
+
if (!xml || !xml->name || !len)
return; /* sanity check */
@@ -632,7 +655,7 @@
/* called when parser finds closing tag */
static switch_xml_t switch_xml_close_tag(switch_xml_root_t root, char *name, char *s)
{
- if (!root->cur || !root->cur->name || strcmp(name, root->cur->name))
+ if (!root || !root->cur || !root->cur->name || strcmp(name, root->cur->name))
return switch_xml_err(root, s, "unexpected closing tag </%s>", name);
root->cur = root->cur->parent;
@@ -681,7 +704,7 @@
return;
}
- if (!root->pi[0]) {
+ if (!root->pi || !root->pi[0]) {
root->pi = (char ***) malloc(sizeof(char **));
if (!root->pi)
return;