[Freeswitch-svn] [commit] r6886 - freeswitch/trunk/src

Freeswitch SVN mikej at freeswitch.org
Tue Dec 18 17:34:46 EST 2007


Author: mikej
Date: Tue Dec 18 17:34:46 2007
New Revision: 6886

Modified:
   freeswitch/trunk/src/switch_xml.cpp

Log:
more error case handling.

Modified: freeswitch/trunk/src/switch_xml.cpp
==============================================================================
--- freeswitch/trunk/src/switch_xml.cpp	(original)
+++ freeswitch/trunk/src/switch_xml.cpp	Tue Dec 18 17:34:46 2007
@@ -496,20 +496,27 @@
 		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



More information about the Freeswitch-svn mailing list