From bc74d0ee81addb9eb7264588ee853d058f32a3b7 Mon Sep 17 00:00:00 2001 From: Felipe Pena Date: Sun, 10 May 2009 15:12:32 +0000 Subject: [PATCH] - 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 d1acdcdd53..10e261834e 100644 --- a/ext/xsl/xsltprocessor.c +++ b/ext/xsl/xsltprocessor.c @@ -154,11 +154,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.s; params[i++] = xpath_expr; + } else { + efree(string_key.s); } } } -- 2.50.1