handle some error cases.

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6879 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris 2007-12-18 21:37:28 +00:00
parent f2eae66ebc
commit 53ce0c1f42
1 changed files with 19 additions and 1 deletions

View 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
}