more error case handling.

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6886 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris 2007-12-18 22:34:46 +00:00
parent 4a5ec93122
commit de58ab2201
1 changed files with 9 additions and 2 deletions

View File

@ -496,20 +496,27 @@ static void switch_xml_proc_inst(switch_xml_root_t root, char *s, switch_size_t
s += strspn(s + 1, SWITCH_XML_WS) + 1; // skip whitespace after target s += strspn(s + 1, SWITCH_XML_WS) + 1; // skip whitespace after target
} }
if (!root) return;
if (!strcmp(target, "xml")) { // <?xml ... ?> if (!strcmp(target, "xml")) { // <?xml ... ?>
if ((s = strstr(s, "standalone")) && !strncmp(s + strspn(s + 10, SWITCH_XML_WS "='\"") + 10, "yes", 3)) if ((s = strstr(s, "standalone")) && !strncmp(s + strspn(s + 10, SWITCH_XML_WS "='\"") + 10, "yes", 3))
root->standalone = 1; root->standalone = 1;
return; return;
} }
if (!root->pi[0]) if (!root->pi[0]) {
*(root->pi = (char ***)malloc(sizeof(char **))) = NULL; //first pi 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])) while (root->pi[i] && strcmp(target, root->pi[i][0]))
i++; // find target i++; // find target
if (!root->pi[i]) { // new target if (!root->pi[i]) { // new target
root->pi = (char ***)realloc(root->pi, sizeof(char **) * (i + 2)); root->pi = (char ***)realloc(root->pi, sizeof(char **) * (i + 2));
if (!root->pi) return;
root->pi[i] = (char **)malloc(sizeof(char *) * 3); root->pi[i] = (char **)malloc(sizeof(char *) * 3);
if (!root->pi[i]) return;
root->pi[i][0] = target; root->pi[i][0] = target;
root->pi[i][1] = (char *) (root->pi[i + 1] = NULL); // terminate pi list root->pi[i][1] = (char *) (root->pi[i + 1] = NULL); // terminate pi list
root->pi[i][2] = strdup(""); // empty document position list root->pi[i][2] = strdup(""); // empty document position list