[Freeswitch-trunk] [commit] r6881 - freeswitch/trunk/src

Freeswitch SVN mikej at freeswitch.org
Tue Dec 18 16:59:48 EST 2007


Author: mikej
Date: Tue Dec 18 16:59:48 2007
New Revision: 6881

Modified:
   freeswitch/trunk/src/switch_xml.cpp

Log:
handle some error cases.

Modified: freeswitch/trunk/src/switch_xml.cpp
==============================================================================
--- freeswitch/trunk/src/switch_xml.cpp	(original)
+++ freeswitch/trunk/src/switch_xml.cpp	Tue Dec 18 16:59:48 2007
@@ -431,9 +431,21 @@
 	if (!*(xml->txt))
 		xml->txt = s;			// initial character content
 	else {						// allocate our own memory and make a copy
-		xml->txt = (xml->flags & SWITCH_XML_TXTM)	// allocate some space
-			? (char *)realloc(xml->txt, (l = strlen(xml->txt)) + len)
-			: strcpy((char *)malloc((l = strlen(xml->txt)) + len), xml->txt);
+		if ((xml->flags & SWITCH_XML_TXTM)) { // allocate some space
+			char *tmp = (char *)realloc(xml->txt, (l = strlen(xml->txt)) + len);
+			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
 		if (s != m)
 			free(s);			// free s if it was malloced by switch_xml_decode()



More information about the Freeswitch-trunk mailing list