]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
more error case handling.
authorMichael Jerris <mike@jerris.com>
Tue, 18 Dec 2007 22:34:46 +0000 (22:34 +0000)
committerMichael Jerris <mike@jerris.com>
Tue, 18 Dec 2007 22:34:46 +0000 (22:34 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6886 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/switch_xml.cpp

index acc4795c657e792a77fe1c258be2e30732811db2..e00ff0cff601d5afbf1b23c2414638d064a2bf77 100644 (file)
@@ -496,20 +496,27 @@ static void switch_xml_proc_inst(switch_xml_root_t root, char *s, switch_size_t
                s += strspn(s + 1, SWITCH_XML_WS) + 1;  // skip whitespace after target
        }
 
+       if (!root) return;
+
        if (!strcmp(target, "xml")) {   // <?xml ... ?>
                if ((s = strstr(s, "standalone")) && !strncmp(s + strspn(s + 10, SWITCH_XML_WS "='\"") + 10, "yes", 3))
                        root->standalone = 1;
                return;
        }
 
-       if (!root->pi[0])
-               *(root->pi = (char ***)malloc(sizeof(char **))) = NULL; //first pi
+       if (!root->pi[0]) {
+               root->pi = (char ***)malloc(sizeof(char **));
+               if (!root->pi) return;
+               *(root->pi) = NULL;     //first pi
+       }
 
        while (root->pi[i] && strcmp(target, root->pi[i][0]))
                i++;                                    // find target
        if (!root->pi[i]) {                     // new target
                root->pi = (char ***)realloc(root->pi, sizeof(char **) * (i + 2));
+               if (!root->pi) return;
                root->pi[i] = (char **)malloc(sizeof(char *) * 3);
+               if (!root->pi[i]) return;
                root->pi[i][0] = target;
                root->pi[i][1] = (char *) (root->pi[i + 1] = NULL);     // terminate pi list
                root->pi[i][2] = strdup("");    // empty document position list