Browse Source

fix for bug #22786 ("Crash when trying to call DomAttribute's set_namespace method")

migration/unlabaled-1.3.2
Christian Stocker 24 years ago
parent
commit
0cc4b081a3
  1. 14
      ext/domxml/php_domxml.c

14
ext/domxml/php_domxml.c

@ -3352,7 +3352,11 @@ PHP_FUNCTION(domxml_node_set_namespace)
/* if node is in a document, search for an already existing namespace */
if (nodep->doc != NULL) {
nsptr = xmlSearchNsByHref(nodep->doc, nodep, (xmlChar*) uri);
if (nodep->type == XML_ATTRIBUTE_NODE) {
nsptr = xmlSearchNsByHref(nodep->doc, nodep->parent, (xmlChar*) uri);
} else {
nsptr = xmlSearchNsByHref(nodep->doc, nodep, (xmlChar*) uri);
}
} else {
nsptr = NULL;
}
@ -3367,9 +3371,13 @@ PHP_FUNCTION(domxml_node_set_namespace)
sprintf(prefixtmp, "a%d", random);
prefix = prefixtmp;
}
nsptr = xmlNewNs(nodep, uri, prefix);
if (nodep->type == XML_ATTRIBUTE_NODE) {
nsptr = xmlNewNs(nodep->parent, uri, prefix);
} else {
nsptr = xmlNewNs(nodep, uri, prefix);
}
}
xmlSetNs(nodep, nsptr);
}
/* }}} */

Loading…
Cancel
Save