]> granicus.if.org Git - php/commitdiff
MFB: fix bug #39625 (Apache crashes on importStylesheet call)
authorRob Richards <rrichards@php.net>
Tue, 5 Dec 2006 12:05:03 +0000 (12:05 +0000)
committerRob Richards <rrichards@php.net>
Tue, 5 Dec 2006 12:05:03 +0000 (12:05 +0000)
ext/xsl/xsltprocessor.c

index 103ece66d520b97f9014473c00198d6e1080d42d..db18723aeb64389cdf5cb11da9f31c9cd8610ca6 100644 (file)
@@ -385,13 +385,15 @@ PHP_FUNCTION(xsl_xsltprocessor_import_stylesheet)
        efree(member);
        if (clone_docu == 0) {
                /* check if the stylesheet is using xsl:key, if yes, we have to clone the document _always_ before a transformation */
-               nodep = xmlDocGetRootElement(sheetp->doc)->children;
-               while (nodep) {
-                       if (nodep->type == XML_ELEMENT_NODE && xmlStrEqual(nodep->name, "key") && xmlStrEqual(nodep->ns->href, XSLT_NAMESPACE)) {
-                               intern->hasKeys = 1;
-                               break;
+               nodep = xmlDocGetRootElement(sheetp->doc);
+               if (nodep && (nodep = nodep->children)) {
+                       while (nodep) {
+                               if (nodep->type == XML_ELEMENT_NODE && xmlStrEqual(nodep->name, "key") && xmlStrEqual(nodep->ns->href, XSLT_NAMESPACE)) {
+                                       intern->hasKeys = 1;
+                                       break;
+                               }
+                               nodep = nodep->next;
                        }
-                       nodep = nodep->next;
                }
        } else {
                intern->hasKeys = clone_docu;