diff options
author | Chris Jarecki <zenderx@php.net> | 2002-01-21 19:12:00 +0000 |
---|---|---|
committer | Chris Jarecki <zenderx@php.net> | 2002-01-21 19:12:00 +0000 |
commit | 5f153ca92912e2565b410f5e285a66fe2cfeeade (patch) | |
tree | f59361a7712001a4988b7506baff45eac120396d | |
parent | 6aa6a6ab87eeeadf67dbe71e2f73366d9ff5f92d (diff) | |
download | php-git-5f153ca92912e2565b410f5e285a66fe2cfeeade.tar.gz |
- fixed bug caused by libxml2 in xpath_register_ns()
- registered namespaces are now persistent
-rw-r--r-- | ext/domxml/php_domxml.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/ext/domxml/php_domxml.c b/ext/domxml/php_domxml.c index 17c994a4a2..7e6e9b977a 100644 --- a/ext/domxml/php_domxml.c +++ b/ext/domxml/php_domxml.c @@ -3285,20 +3285,25 @@ PHP_FUNCTION(xpath_register_ns) { /* TODO: - - make the namespace registration persistent - now it dissapears each time xpath_eval is called - automagically register all namespaces when creating a new context */ int prefix_len, uri_len, result; xmlXPathContextPtr ctxp; - char *prefix, *uri; + char *prefix, *uri, *uri_static; zval *id; DOMXML_PARAM_FOUR(ctxp, id, le_xpathctxp, "ss", &prefix, &prefix_len, &uri, &uri_len); /* set the context node to NULL - what is a context node anyway? */ ctxp->node = NULL; - result = xmlXPathRegisterNs(ctxp, prefix, uri); + + /* + this is a hack - libxml2 doesn't copy the URI, it simply uses the string + given in the parameter - which is normally deallocated after the function + */ + uri_static = estrndup(uri, uri_len); + result = xmlXPathRegisterNs(ctxp, prefix, uri_static); if (0 == result) { RETURN_TRUE; |