1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Merge branch 'PHP-8.3' into PHP-8.4

* PHP-8.3:
  Fix memory leak in tidy output handler on error
  Fix leaks with multiple calls to DatePeriod iterator current()
This commit is contained in:
Niels Dossche
2025-05-26 19:42:20 +02:00
4 changed files with 54 additions and 5 deletions

6
NEWS
View File

@@ -11,6 +11,9 @@ PHP NEWS
evaluation) and GH-18464 (Recursion protection for deprecation constants not
released on bailout). (DanielEScherzer and ilutov)
- Date:
. Fix leaks with multiple calls to DatePeriod iterator current(). (nielsdos)
- Intl:
. Fix memory leak in intl_datetime_decompose() on failure. (nielsdos)
@@ -28,6 +31,9 @@ PHP NEWS
- Soap:
. Fix memory leaks in php_http.c when call_user_function() fails. (nielsdos)
- Tidy:
. Fix memory leak in tidy output handler on error. (nielsdos)
06 Jun 2025, PHP 8.4.8
- Core:

View File

@@ -1617,6 +1617,7 @@ static zval *date_period_it_current_data(zend_object_iterator *iter)
php_date_obj *newdateobj;
/* Create new object */
zval_ptr_dtor(&iterator->current);
php_date_instantiate(get_base_date_class(object->start_ce), &iterator->current);
newdateobj = Z_PHPDATE_P(&iterator->current);
newdateobj->time = timelib_time_ctor();

View File

@@ -0,0 +1,42 @@
--TEST--
Multiple calls to DatePeriod iterator current() leak objects
--FILE--
<?php
$start = new DateTime('2018-12-31 00:00:00');
$end = new DateTime('2019-12-31 00:00:00');
$interval = new DateInterval('P1M');
$period = new DatePeriod($start, $interval, 1);
$iter = $period->getIterator();
var_dump($iter->current());
var_dump($iter->current());
$iter->current()->setTimestamp(0);
var_dump($iter->current());
?>
--EXPECT--
object(DateTime)#9 (3) {
["date"]=>
string(26) "2018-12-31 00:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(3) "UTC"
}
object(DateTime)#9 (3) {
["date"]=>
string(26) "2018-12-31 00:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(3) "UTC"
}
object(DateTime)#9 (3) {
["date"]=>
string(26) "2018-12-31 00:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(3) "UTC"
}

View File

@@ -961,6 +961,11 @@ static zend_result php_tidy_output_handler(void **nothing, php_output_context *o
TidyBuffer inbuf, outbuf, errbuf;
if (TG(clean_output) && (output_context->op & PHP_OUTPUT_HANDLER_START) && (output_context->op & PHP_OUTPUT_HANDLER_FINAL)) {
if (ZEND_SIZE_T_UINT_OVFL(output_context->in.used)) {
php_error_docref(NULL, E_WARNING, "Input string is too long");
return status;
}
doc = tidyCreate();
tidyBufInit(&errbuf);
@@ -968,11 +973,6 @@ static zend_result php_tidy_output_handler(void **nothing, php_output_context *o
tidyOptSetBool(doc, TidyForceOutput, yes);
tidyOptSetBool(doc, TidyMark, no);
if (ZEND_SIZE_T_UINT_OVFL(output_context->in.used)) {
php_error_docref(NULL, E_WARNING, "File content is too long");
return status;
}
TIDY_SET_DEFAULT_CONFIG(doc);
tidyBufInit(&inbuf);