summaryrefslogtreecommitdiff
path: root/ext/domxml/php_domxml.c
diff options
context:
space:
mode:
authorChristian Stocker <chregu@php.net>2003-03-20 09:43:09 +0000
committerChristian Stocker <chregu@php.net>2003-03-20 09:43:09 +0000
commitc479e904ddaf1d94a18c84638e3df1109f02b616 (patch)
tree36e0bb3d3b4670050e484342f69ed8e8003dd271 /ext/domxml/php_domxml.c
parent893c567e3589d04ed31519b962cc2837e95de908 (diff)
downloadphp-git-c479e904ddaf1d94a18c84638e3df1109f02b616.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 31e2c259f2..f7782e791e 100644
--- a/ext/domxml/php_domxml.c
+++ b/ext/domxml/php_domxml.c
@@ -3339,7 +3339,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;
}
@@ -3354,9 +3358,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);
}
/* }}} */