[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pecl-cvs
Subject:    [PECL-CVS] com =?UTF-8?Q?pecl/file=5Fformats/yaml=3A=20Fix=20memory=20leak=20in=20y?= =?UTF-8?Q?=5Fw
From:       Bryan Davis <bd808 () php ! net>
Date:       2020-12-16 17:32:40
Message-ID: php-mail-13901ec30b01ec3f9040576fa725782a185017778 () git ! php ! net
[Download RAW message or body]

Commit:    190a6708abb1083e76e9850df187d9abb3354807
Author:    Christoph M. Becker <cmbecker69@gmx.de>         Wed, 16 Dec 2020 18:31:04 \
                +0100
Parents:   0c81894dfdf0373404532eb3832a51e647c3717e
Branches:  php7

Link:       http://git.php.net/?p=pecl/file_formats/yaml.git;a=commitdiff;h=190a6708abb1083e76e9850df187d9abb3354807


Log:
Fix memory leak in y_write_object_callback()

We need to release the `retval` of `call_user_function()`.

This memory leak could be observed when running `yaml_emit_008.phpt`
and `yaml_emit_009.phpt` with a debug build or under a leak checker.

Changed paths:
  M  emit.c


Diff:
diff --git a/emit.c b/emit.c
index 284a59f..b93db5a 100644
--- a/emit.c
+++ b/emit.c
@@ -718,6 +718,7 @@ y_write_object_callback (
 	zval *ztag;
 	zval *zdata;
 	zend_string *str_key;
+	int result;
 
 	/* call the user function */
 	if (FAILURE == call_user_function(EG(function_table), NULL,
@@ -734,6 +735,7 @@ y_write_object_callback (
 		php_error_docref(NULL, E_WARNING,
 				"Expected callback for class '%s'"
 				" to return an array", clazz_name);
+		zval_ptr_dtor(&zret);
 		return FAILURE;
 	}
 
@@ -760,10 +762,12 @@ y_write_object_callback (
 	}
 	zend_string_release(str_key);
 
-
 	/* emit surrogate object and tag */
-	return y_write_zval(
+	result = y_write_zval(
 			state, zdata, (yaml_char_t *) Z_STRVAL_P(ztag));
+
+	zval_ptr_dtor(&zret);
+	return result;
 }
 /* }}} */


--
PECL CVS Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic