From: Rob Richards Date: Thu, 18 Sep 2008 11:46:54 +0000 (+0000) Subject: fix bug #46099 (Xsltprocessor::setProfiling - memory leak) X-Git-Tag: BEFORE_HEAD_NS_CHANGE~361 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b85af358189ec11fe3f6f791908d4c1dc12240b0;p=php fix bug #46099 (Xsltprocessor::setProfiling - memory leak) --- diff --git a/ext/xsl/php_xsl.c b/ext/xsl/php_xsl.c index aca22a556b..c6eff88e5f 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 80942970a5..d441ff7738 100644 --- a/ext/xsl/xsltprocessor.c +++ b/ext/xsl/xsltprocessor.c @@ -555,10 +555,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; @@ -882,13 +878,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;