Skip to content

Commit a109fdd

Browse files
committed
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).
1 parent c429444 commit a109fdd

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

ext/date/php_date.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5278,21 +5278,14 @@ PHP_METHOD(DatePeriod, __wakeup)
52785278
/* {{{ date_period_read_property */
52795279
static zval *date_period_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv)
52805280
{
5281-
zval *zv;
52825281
if (type != BP_VAR_IS && type != BP_VAR_R) {
52835282
zend_throw_error(NULL, "Retrieval of DatePeriod properties for modification is unsupported");
52845283
return &EG(uninitialized_zval);
52855284
}
52865285

52875286
Z_OBJPROP_P(object); /* build properties hash table */
52885287

5289-
zv = std_object_handlers.read_property(object, member, type, cache_slot, rv);
5290-
if (Z_TYPE_P(zv) == IS_OBJECT && Z_OBJ_HANDLER_P(zv, clone_obj)) {
5291-
/* defensive copy */
5292-
ZVAL_OBJ(zv, Z_OBJ_HANDLER_P(zv, clone_obj)(zv));
5293-
}
5294-
5295-
return zv;
5288+
return std_object_handlers.read_property(object, member, type, cache_slot, rv);
52965289
}
52975290
/* }}} */
52985291

0 commit comments

Comments
 (0)