]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
handle some error cases.
authorMichael Jerris <mike@jerris.com>
Tue, 18 Dec 2007 21:37:28 +0000 (21:37 +0000)
committerMichael Jerris <mike@jerris.com>
Tue, 18 Dec 2007 21:37:28 +0000 (21:37 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6879 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/switch_xml.cpp

index e8d38b33c0f0d04375d1f61c66e03ad958495920..e786a1e629c06ee3973169d3f6e71dcb3d0246ca 100644 (file)
@@ -356,7 +356,25 @@ static char *switch_xml_decode(char *s, char **ent, char t)
                        if (ent[b++]) {         // found a match
                                if ((c = (long) strlen(ent[b])) - 1 > (e = strchr(s, ';')) - s) {
                                        l = (d = (long) (s - r)) + c + (long) strlen(e);        // new length
-                                       r = (r == m) ? strcpy((char *)malloc(l), r) : (char *)realloc(r, l);
+                                       if (l) {
+                                               if (r == m) {
+                                                       char *tmp = (char *)malloc(l);
+                                                       if (tmp) {
+                                                               r = strcpy(tmp, r);
+                                                       } else {
+                                                               if (r) free(r);
+                                                               return NULL;
+                                                       }
+                                               } else {
+                                                       char *tmp = (char *)realloc(r, l);
+                                                       if (tmp) {
+                                                               r = tmp;
+                                                       } else {
+                                                               if (r) free(r);
+                                                               return NULL;
+                                                       }
+                                               }
+                                       }
                                        e = strchr((s = r + d), ';');   // fix up pointers
                                }