com php-src: Remove "defensive copy" of DatePeriod properties: ext/date/php_date.c

From: Date: Tue, 12 Feb 2019 08:54:52 +0000
Subject: com php-src: Remove "defensive copy" of DatePeriod properties: ext/date/php_date.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-104576@lists.php.net to get a copy of this message
Commit: a109fddba4e3fbb6e3a2e008c0fa20a57f26103d Author: Nikita Popov <nikita.ppv@gmail.com> Tue, 12 Feb 2019 09:54:52 +0100 Parents: c4294440ffc4a59a1298292b76072e6759034a68 Branches: PHP-7.2 PHP-7.3 PHP-7.4 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=a109fddba4e3fbb6e3a2e008c0fa20a57f26103d Log: Remove "defensive copy" of DatePeriod properties get_properties() constructs these as fresh objects with no relation to the internals, there is no need to clone them again. Additionally the current implementation leaks memory, because the original objects are never freed (see PR #3121). Bugs: https://bugs.php.net/3121 Changed paths: M ext/date/php_date.c Diff: diff --git a/ext/date/php_date.c b/ext/date/php_date.c index 1e136e0..c8479b5 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -5278,7 +5278,6 @@ PHP_METHOD(DatePeriod, __wakeup) /* {{{ date_period_read_property */ static zval *date_period_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv) { - zval *zv; if (type != BP_VAR_IS && type != BP_VAR_R) { zend_throw_error(NULL, "Retrieval of DatePeriod properties for modification is unsupported"); return &EG(uninitialized_zval); @@ -5286,13 +5285,7 @@ static zval *date_period_read_property(zval *object, zval *member, int type, voi Z_OBJPROP_P(object); /* build properties hash table */ - zv = std_object_handlers.read_property(object, member, type, cache_slot, rv); - if (Z_TYPE_P(zv) == IS_OBJECT && Z_OBJ_HANDLER_P(zv, clone_obj)) { - /* defensive copy */ - ZVAL_OBJ(zv, Z_OBJ_HANDLER_P(zv, clone_obj)(zv)); - } - - return zv; + return std_object_handlers.read_property(object, member, type, cache_slot, rv); } /* }}} */

« previous php.cvs (#104576) next »