diff --git a/ext/date/php_date.c b/ext/date/php_date.c index 5ee48ab5538..c57353ce4e8 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -5077,6 +5077,9 @@ static bool php_date_period_initialize_from_hash(php_period_obj *period_obj, Has if (Z_TYPE_P(ht_entry) == IS_OBJECT && instanceof_function(Z_OBJCE_P(ht_entry), date_ce_interface)) { php_date_obj *date_obj; date_obj = Z_PHPDATE_P(ht_entry); + if (period_obj->start != NULL) { + timelib_time_dtor(period_obj->start); + } period_obj->start = timelib_time_clone(date_obj->time); period_obj->start_ce = Z_OBJCE_P(ht_entry); } else if (Z_TYPE_P(ht_entry) != IS_NULL) { @@ -5091,6 +5094,9 @@ static bool php_date_period_initialize_from_hash(php_period_obj *period_obj, Has if (Z_TYPE_P(ht_entry) == IS_OBJECT && instanceof_function(Z_OBJCE_P(ht_entry), date_ce_interface)) { php_date_obj *date_obj; date_obj = Z_PHPDATE_P(ht_entry); + if (period_obj->end != NULL) { + timelib_time_dtor(period_obj->end); + } period_obj->end = timelib_time_clone(date_obj->time); } else if (Z_TYPE_P(ht_entry) != IS_NULL) { return 0; @@ -5104,6 +5110,9 @@ static bool php_date_period_initialize_from_hash(php_period_obj *period_obj, Has if (Z_TYPE_P(ht_entry) == IS_OBJECT && instanceof_function(Z_OBJCE_P(ht_entry), date_ce_interface)) { php_date_obj *date_obj; date_obj = Z_PHPDATE_P(ht_entry); + if (period_obj->current != NULL) { + timelib_time_dtor(period_obj->current); + } period_obj->current = timelib_time_clone(date_obj->time); } else if (Z_TYPE_P(ht_entry) != IS_NULL) { return 0; @@ -5117,6 +5126,9 @@ static bool php_date_period_initialize_from_hash(php_period_obj *period_obj, Has if (Z_TYPE_P(ht_entry) == IS_OBJECT && Z_OBJCE_P(ht_entry) == date_ce_interval) { php_interval_obj *interval_obj; interval_obj = Z_PHPINTERVAL_P(ht_entry); + if (period_obj->interval != NULL) { + timelib_rel_time_dtor(period_obj->interval); + } period_obj->interval = timelib_rel_time_clone(interval_obj->diff); } else { /* interval is required */ return 0;