com php-src: fix bug #49634x: NEWS ext/xsl/tests/bug49634.phpt ext/xsl/tests/bug49634.xml ext/xsl/xsltprocessor.c

From: Date: Mon, 02 Dec 2013 11:10:00 +0000
Subject: com php-src: fix bug #49634x: NEWS ext/xsl/tests/bug49634.phpt ext/xsl/tests/bug49634.xml ext/xsl/xsltprocessor.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-74198@lists.php.net to get a copy of this message
Commit: 6408a1a59e6d371cd488687e28e18815ea97984e Author: Michael Wallner <mike@php.net> Mon, 2 Dec 2013 12:08:22 +0100 Parents: edbefd1d5c5c466f1e32461f3a7298b588038cb5 Branches: PHP-5.4 PHP-5.5 PHP-5.6 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=6408a1a59e6d371cd488687e28e18815ea97984e Log: fix bug #49634x Bugs: https://bugs.php.net/49634 Changed paths: M NEWS A ext/xsl/tests/bug49634.phpt A ext/xsl/tests/bug49634.xml M ext/xsl/xsltprocessor.c Diff: diff --git a/NEWS b/NEWS index f55ff05..bf759c8 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,10 @@ PHP NEWS 1600). (Derick, T. Carter) . Fixed bug #61599 (Wrong Day of Week).. (Derick, T. Carter) +- XSL + . Fixed bug #49634 (Segfault throwing an exception in a XSL registered + function). (Mike) + ?? ??? 2013, PHP 5.4.23 - Core: diff --git a/ext/xsl/tests/bug49634.phpt b/ext/xsl/tests/bug49634.phpt new file mode 100644 index 0000000..b009fd5 --- /dev/null +++ b/ext/xsl/tests/bug49634.phpt @@ -0,0 +1,105 @@ +--TEST-- +bug #49634 (Segfault throwing an exception in a XSL registered function) +--SKIPIF-- +<?php +extension_loaded("xsl") or die("skip need ext/xsl"); +?> +--FILE-- +<?php + +$sXml = <<<XML +<?xml version="1.0" encoding="UTF-8" ?> +<root> + test +</root> +XML; + +$cDIR = __DIR__; +$sXsl = <<<XSL +<xsl:stylesheet version="1.0" + xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:ext="http://php.net/xsl" + xsl:extension-element-prefixes="ext" + exclude-result-prefixes="ext"> + <xsl:output encoding="UTF-8" indent="yes" method="xml" /> + <xsl:template match="/"> + <xsl:value-of select="ext:function('testFunction', document('$cDIR/bug49634.xml')/root)"/> + </xsl:template> +</xsl:stylesheet> +XSL; + +function testFunction($a) +{ + throw new Exception('Test exception.'); +} + +$domXml = new DOMDocument; +$domXml->loadXML($sXml); +$domXsl = new DOMDocument; +$domXsl->loadXML($sXsl); + +for ($i = 0; $i < 10; $i++) +{ + $xsltProcessor = new XSLTProcessor(); + $xsltProcessor->registerPHPFunctions(array('testFunction')); + $xsltProcessor->importStyleSheet($domXsl); + try { + @$xsltProcessor->transformToDoc($domXml); + } catch (Exception $e) { + echo $e,"\n"; + } +} +?> +===DONE=== +--EXPECTF-- +exception 'Exception' with message 'Test exception.' in %s:%d +Stack trace: +#0 [internal function]: testFunction(Array) +#1 %s(%d): XSLTProcessor->transformToDoc(Object(DOMDocument)) +#2 {main} +exception 'Exception' with message 'Test exception.' in %s:%d +Stack trace: +#0 [internal function]: testFunction(Array) +#1 %s(%d): XSLTProcessor->transformToDoc(Object(DOMDocument)) +#2 {main} +exception 'Exception' with message 'Test exception.' in %s:%d +Stack trace: +#0 [internal function]: testFunction(Array) +#1 %s(%d): XSLTProcessor->transformToDoc(Object(DOMDocument)) +#2 {main} +exception 'Exception' with message 'Test exception.' in %s:%d +Stack trace: +#0 [internal function]: testFunction(Array) +#1 %s(%d): XSLTProcessor->transformToDoc(Object(DOMDocument)) +#2 {main} +exception 'Exception' with message 'Test exception.' in %s:%d +Stack trace: +#0 [internal function]: testFunction(Array) +#1 %s(%d): XSLTProcessor->transformToDoc(Object(DOMDocument)) +#2 {main} +exception 'Exception' with message 'Test exception.' in %s:%d +Stack trace: +#0 [internal function]: testFunction(Array) +#1 %s(%d): XSLTProcessor->transformToDoc(Object(DOMDocument)) +#2 {main} +exception 'Exception' with message 'Test exception.' in %s:%d +Stack trace: +#0 [internal function]: testFunction(Array) +#1 %s(%d): XSLTProcessor->transformToDoc(Object(DOMDocument)) +#2 {main} +exception 'Exception' with message 'Test exception.' in %s:%d +Stack trace: +#0 [internal function]: testFunction(Array) +#1 %s(%d): XSLTProcessor->transformToDoc(Object(DOMDocument)) +#2 {main} +exception 'Exception' with message 'Test exception.' in %s:%d +Stack trace: +#0 [internal function]: testFunction(Array) +#1 %s(%d): XSLTProcessor->transformToDoc(Object(DOMDocument)) +#2 {main} +exception 'Exception' with message 'Test exception.' in %s:%d +Stack trace: +#0 [internal function]: testFunction(Array) +#1 %s(%d): XSLTProcessor->transformToDoc(Object(DOMDocument)) +#2 {main} +===DONE=== diff --git a/ext/xsl/tests/bug49634.xml b/ext/xsl/tests/bug49634.xml new file mode 100644 index 0000000..f3f286e --- /dev/null +++ b/ext/xsl/tests/bug49634.xml @@ -0,0 +1 @@ +<root/> diff --git a/ext/xsl/xsltprocessor.c b/ext/xsl/xsltprocessor.c index af11104..f5acc14 100644 --- a/ext/xsl/xsltprocessor.c +++ b/ext/xsl/xsltprocessor.c @@ -279,7 +279,10 @@ static void xsl_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs, int t node->type = XML_NAMESPACE_DECL; node->parent = nsparent; node->ns = curns; + } else { + node = xmlDocCopyNodeList(domintern->document->ptr, node); } + child = php_dom_create_object(node, &ret, child, domintern TSRMLS_CC); add_next_index_zval(args[i], child); }

« previous php.cvs (#74198) next »