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

List:       php-cvs
Subject:    [PHP-CVS] [php-src] master: Fixed memory leak with manual calls to DateInterval::__unserialize
From:       Derick Rethans <noreply () php ! net>
Date:       2022-04-29 15:38:30
Message-ID: zVh7eEKqKMpQgbsyV4Cve64kjgtKravfrGx3NdZU () main ! php ! net
[Download RAW message or body]

Author: Derick Rethans (derickr)
Date: 2022-04-29T10:27:40+01:00

Commit: https://github.com/php/php-src/commit/76e852e7e8ba20901d33ccf405ba85e914870768
 Raw diff: https://github.com/php/php-src/commit/76e852e7e8ba20901d33ccf405ba85e914870768.diff


Fixed memory leak with manual calls to DateInterval::__unserialize

Changed paths:
  M  ext/date/php_date.c


Diff:

diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index 636e4f874e9f..7dc885d56aae 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -4104,6 +4104,12 @@ PHP_METHOD(DateInterval, __construct)
 
 static void php_date_interval_initialize_from_hash(zval **return_value, \
php_interval_obj **intobj, HashTable *myht) /* {{{ */  {
+	/* If ->diff is already set, then we need to free it first */
+	if ((*intobj)->diff) {
+		timelib_rel_time_dtor((*intobj)->diff);
+	}
+
+	/* Set new value */
 	(*intobj)->diff = timelib_rel_time_ctor();
 
 #define PHP_DATE_INTERVAL_READ_PROPERTY(element, member, itype, def) \

-- 
PHP CVS Mailing List (http://www.php.net/)
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