1
0
mirror of https://github.com/php/php-src.git synced 2026-04-03 14:12:38 +02:00

Fixed memory leaks with DatePeriod::__unserialise

This commit is contained in:
Derick Rethans
2022-07-15 11:03:12 +01:00
parent 09237f6126
commit 0dbedb3dbd

View File

@@ -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;