From 680bc45ba5c31988e4a6be2a9f4d779baea8c37e Mon Sep 17 00:00:00 2001 From: Felipe Pena Date: Sun, 10 May 2009 15:13:05 +0000 Subject: [PATCH] - MFH: Fixed bug #48221 (memory leak when passing invalid xslt parameter) --- ext/xsl/tests/bug48221.phpt | 85 +++++++++++++++++++++++++++++++++++++ ext/xsl/xsltprocessor.c | 4 +- 2 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 ext/xsl/tests/bug48221.phpt diff --git a/ext/xsl/tests/bug48221.phpt b/ext/xsl/tests/bug48221.phpt new file mode 100644 index 0000000000..609112db3d --- /dev/null +++ b/ext/xsl/tests/bug48221.phpt @@ -0,0 +1,85 @@ +--TEST-- +Bug #48221 (memory leak when passing invalid xslt parameter) +--SKIPIF-- + +--FILE-- +loadXML(' + + Sales Results By Division + + + + + + + + + + + + + + + + + + + +
DivisionRevenueGrowthBonus
+ + + + + + + + color:red + + + + + +
+ +'); + +$dom = new DOMDocument; +$dom->loadXMl(' + + + 10 + 9 + 7 + + + + 4 + 3 + 4 + + + + 6 + -1.5 + 2 + + +'); + +$proc = new xsltprocessor; +$proc->importStylesheet($xsl); +$proc->setParameter('', '', '"\''); +$proc->transformToXml($dom); + +?> +--EXPECTF-- +Warning: XSLTProcessor::transformToXml(): Cannot create XPath expression (string contains both quote and double-quotes) in %s on line %d diff --git a/ext/xsl/xsltprocessor.c b/ext/xsl/xsltprocessor.c index 7f26ce88fb..fe23f2a446 100644 --- a/ext/xsl/xsltprocessor.c +++ b/ext/xsl/xsltprocessor.c @@ -153,11 +153,13 @@ static char **php_xsl_xslt_make_params(HashTable *parht, int xpath_params TSRMLS if (!xpath_params) { xpath_expr = php_xsl_xslt_string_to_xpathexpr(Z_STRVAL_PP(value) TSRMLS_CC); } else { - xpath_expr = estrndup(Z_STRVAL_PP(value), strlen(Z_STRVAL_PP(value))); + xpath_expr = estrndup(Z_STRVAL_PP(value), Z_STRLEN_PP(value)); } if (xpath_expr) { params[i++] = string_key; params[i++] = xpath_expr; + } else { + efree(string_key); } } } -- 2.40.0