From: Rob Richards Date: Thu, 18 Sep 2008 11:47:59 +0000 (+0000) Subject: MFH: fix bug #46099 (Xsltprocessor::setProfiling - memory leak) X-Git-Tag: BEFORE_NS_RULES_CHANGE~364 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=24e9b9119308731504ca6c2e1de80471f1fd9aea;p=php MFH: fix bug #46099 (Xsltprocessor::setProfiling - memory leak) --- diff --git a/ext/xsl/php_xsl.c b/ext/xsl/php_xsl.c index 957a3be2e1..2f19afa665 100644 --- a/ext/xsl/php_xsl.c +++ b/ext/xsl/php_xsl.c @@ -103,6 +103,9 @@ void xsl_objects_free_storage(void *object TSRMLS_DC) xsltFreeStylesheet((xsltStylesheetPtr) intern->ptr); intern->ptr = NULL; } + if (intern->profiling) { + efree(intern->profiling); + } efree(object); } /* }}} */ diff --git a/ext/xsl/xsltprocessor.c b/ext/xsl/xsltprocessor.c index 3def1c65a9..0d49f7c51f 100644 --- a/ext/xsl/xsltprocessor.c +++ b/ext/xsl/xsltprocessor.c @@ -554,10 +554,6 @@ static xmlDocPtr php_xsl_apply_stylesheet(zval *id, xsl_object *intern, xsltStyl php_libxml_decrement_doc_ref(intern->doc TSRMLS_CC); efree(intern->doc); intern->doc = NULL; - - if (intern->profiling) { - efree(intern->profiling); - } if (params) { clone = 0; @@ -849,13 +845,20 @@ PHP_FUNCTION(xsl_xsltprocessor_set_profiling) { zval *id; xsl_object *intern; - char *filename; + char *filename = NULL; int filename_len; DOM_GET_THIS(id); - if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == SUCCESS) { + if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "s!", &filename, &filename_len) == SUCCESS) { intern = (xsl_object *)zend_object_store_get_object(id TSRMLS_CC); - intern->profiling = estrndup(filename,filename_len); + if (intern->profiling) { + efree(intern->profiling); + } + if (filename != NULL) { + intern->profiling = estrndup(filename,filename_len); + } else { + intern->profiling = NULL; + } RETURN_TRUE; } else { WRONG_PARAM_COUNT;