]> granicus.if.org Git - php/commitdiff
- fixed bug caused by libxml2 in xpath_register_ns()
authorChris Jarecki <zenderx@php.net>
Mon, 21 Jan 2002 19:12:00 +0000 (19:12 +0000)
committerChris Jarecki <zenderx@php.net>
Mon, 21 Jan 2002 19:12:00 +0000 (19:12 +0000)
- registered namespaces are now persistent

ext/domxml/php_domxml.c

index 17c994a4a246859e9a67340c2f3628b410657840..7e6e9b977a2f2a8cd73f66c0e79876b5686e2e8d 100644 (file)
@@ -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;