summaryrefslogtreecommitdiff
path: root/ext/domxml/php_domxml.c
diff options
context:
space:
mode:
authorChristian Stocker <chregu@php.net>2003-03-20 09:48:19 +0000
committerChristian Stocker <chregu@php.net>2003-03-20 09:48:19 +0000
commit0cc4b081a34187a8ca41a086b052267bbacb8381 (patch)
tree677f30908e46697ca2facd407af19a79a45bac8a /ext/domxml/php_domxml.c
parent87a06aa8eaacb9d0fb4765b85a2efe1d0db1657d (diff)
downloadphp-git-0cc4b081a34187a8ca41a086b052267bbacb8381.tar.gz
fix for bug #22786 ("Crash when trying to call DomAttribute's set_namespace method")
Diffstat (limited to 'ext/domxml/php_domxml.c')
-rw-r--r--ext/domxml/php_domxml.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/ext/domxml/php_domxml.c b/ext/domxml/php_domxml.c
index 91bcb25e15..8262c1be38 100644
--- a/ext/domxml/php_domxml.c
+++ b/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);
}
/* }}} */