]> granicus.if.org Git - php/commitdiff
MFH: fix bug #46099 (Xsltprocessor::setProfiling - memory leak)
authorRob Richards <rrichards@php.net>
Thu, 18 Sep 2008 11:47:59 +0000 (11:47 +0000)
committerRob Richards <rrichards@php.net>
Thu, 18 Sep 2008 11:47:59 +0000 (11:47 +0000)
ext/xsl/php_xsl.c
ext/xsl/xsltprocessor.c

index 957a3be2e1105768a8e469d53054383ca24a01d3..2f19afa665e9a9569d66be1a6481b4cbc3fdf26d 100644 (file)
@@ -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);
 }
 /* }}} */
index 3def1c65a91a56b49b69ea6724b1330f5697f263..0d49f7c51ff7608f65ce4d3274200373b93362e4 100644 (file)
@@ -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;