[php-src] master: Merge branch 'PHP-8.4' into PHP-8.5

From: Date: Wed, 15 Jul 2026 18:50:47 +0000
Subject: [php-src] master: Merge branch 'PHP-8.4' into PHP-8.5
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-140039@lists.php.net to get a copy of this message
Author: Ilija Tovilo (iluuu1994) Date: 2026-07-15T20:50:11+02:00 Commit: https://github.com/php/php-src/commit/670ccf8d029fa48b36d8298855e981f708260fb9 Raw diff: https://github.com/php/php-src/commit/670ccf8d029fa48b36d8298855e981f708260fb9.diff Merge branch 'PHP-8.4' into PHP-8.5 * PHP-8.4: Fix leak on double DatePeriod::__construct() call Changed paths: A ext/date/tests/DatePeriod_double_constructor_call.phpt M NEWS M ext/date/php_date.c Diff: diff --git a/NEWS b/NEWS index 878cf9d5d12e..c35b46d24c08 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,8 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? ????, PHP 8.5.10 +- Date: + . Fixed leak on double DatePeriod::__construct() call. (ilutov) 30 Jul 2026, PHP 8.5.9 diff --git a/ext/date/php_date.c b/ext/date/php_date.c index ad4b4a51101e..887faa3a7709 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -5163,6 +5163,23 @@ PHP_METHOD(DatePeriod, createFromISO8601String) } } +static void date_period_reset(php_period_obj *period_obj) +{ + if (period_obj->start) { + timelib_time_dtor(period_obj->start); + } + if (period_obj->current) { + timelib_time_dtor(period_obj->current); + } + if (period_obj->end) { + timelib_time_dtor(period_obj->end); + } + if (period_obj->interval) { + timelib_rel_time_dtor(period_obj->interval); + } + memset(period_obj, 0, XtOffsetOf(php_period_obj, std)); +} + /* {{{ Creates new DatePeriod object. */ PHP_METHOD(DatePeriod, __construct) { @@ -5184,7 +5201,7 @@ PHP_METHOD(DatePeriod, __construct) } dpobj = Z_PHPPERIOD_P(ZEND_THIS); - dpobj->current = NULL; + date_period_reset(dpobj); if (isostr) { zend_error(E_DEPRECATED, "Calling DatePeriod::__construct(string $isostr, int $options = 0) is deprecated, " @@ -5202,6 +5219,7 @@ PHP_METHOD(DatePeriod, __construct) if (end) { DATE_CHECK_INITIALIZED(Z_PHPDATE_P(end)->time, date_ce_interface); } + DATE_CHECK_INITIALIZED(Z_PHPINTERVAL_P(interval)->initialized, Z_OBJCE_P(interval)); /* init */ php_interval_obj *intobj = Z_PHPINTERVAL_P(interval); diff --git a/ext/date/tests/DatePeriod_double_constructor_call.phpt b/ext/date/tests/DatePeriod_double_constructor_call.phpt new file mode 100644 index 000000000000..551d2727282d --- /dev/null +++ b/ext/date/tests/DatePeriod_double_constructor_call.phpt @@ -0,0 +1,14 @@ +--TEST-- +Double DatePeriod::__construct() call +--FILE-- +<?php + +$start = new \DateTime(); +$interval = new \DateInterval('P1D'); +$period = new \DatePeriod($start, $interval, 1); +$period->__construct($start, $interval, 1); + +?> +===DONE=== +--EXPECT-- +===DONE===

« previous php.cvs (#140039) next »