diff options
author | Rob Richards <rrichards@php.net> | 2008-09-18 11:47:59 +0000 |
---|---|---|
committer | Rob Richards <rrichards@php.net> | 2008-09-18 11:47:59 +0000 |
commit | 24e9b9119308731504ca6c2e1de80471f1fd9aea (patch) | |
tree | b2e9fc3c5231e1cc1d4a0d3d303f1d879d5c9fba /ext/xsl/xsltprocessor.c | |
parent | 46ab8303e11c4c542e4caae889551bb20d66e5b4 (diff) | |
download | php-git-24e9b9119308731504ca6c2e1de80471f1fd9aea.tar.gz |
MFH: fix bug #46099 (Xsltprocessor::setProfiling - memory leak)
Diffstat (limited to 'ext/xsl/xsltprocessor.c')
-rw-r--r-- | ext/xsl/xsltprocessor.c | 17 |
1 files changed, 10 insertions, 7 deletions
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; |