Skip to content

Commit

Permalink
Remove "defensive copy" of DatePeriod properties
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
nikic committed Feb 12, 2019
1 parent c429444 commit a109fdd
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions ext/date/php_date.c
Original file line number Diff line number Diff line change
Expand Up @@ -5278,21 +5278,14 @@ 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);
}

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);
}
/* }}} */

Expand Down

0 comments on commit a109fdd

Please sign in to comment.