From 5ccef7164eb0b0c47cd252c0d8b6f20d5e92e409 Mon Sep 17 00:00:00 2001 From: Rob Richards Date: Tue, 5 Dec 2006 12:05:03 +0000 Subject: [PATCH] MFB: fix bug #39625 (Apache crashes on importStylesheet call) --- ext/xsl/xsltprocessor.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ext/xsl/xsltprocessor.c b/ext/xsl/xsltprocessor.c index 103ece66d52..db18723aeb6 100644 --- a/ext/xsl/xsltprocessor.c +++ b/ext/xsl/xsltprocessor.c @@ -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;