From: Michael Jerris Date: Tue, 18 Dec 2007 21:37:28 +0000 (+0000) Subject: handle some error cases. X-Git-Tag: v1.0-rc1~989 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=53ce0c1f4250b7f790ff1bdbfe962b66d51809bd;p=thirdparty%2Ffreeswitch.git handle some error cases. git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6879 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- diff --git a/src/switch_xml.cpp b/src/switch_xml.cpp index e8d38b33c0..e786a1e629 100644 --- a/src/switch_xml.cpp +++ b/src/switch_xml.cpp @@ -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 }