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

Merge branch 'PHP-8.4' into PHP-8.5

* PHP-8.4:
  Fix GH-20906: Assertion failure when messing up output buffers
This commit is contained in:
ndossche
2026-02-27 18:15:20 +01:00
5 changed files with 83 additions and 3 deletions

4
NEWS
View File

@@ -6,6 +6,10 @@ PHP NEWS
. Fixed bug GH-21052 (Preloaded constant erroneously propagated to file-cached
script). (ilutov)
- Standard:
. Fixed bug GH-20906 (Assertion failure when messing up output buffers).
(ndossche)
12 Mar 2026, PHP 8.5.4
- Core:

View File

@@ -1751,7 +1751,10 @@ PHP_FUNCTION(highlight_file)
}
if (i) {
php_output_start_default();
if (UNEXPECTED(php_output_start_default() != SUCCESS)) {
zend_throw_error(NULL, "Unable to start output handler");
RETURN_THROWS();
}
}
php_get_highlight_struct(&syntax_highlighter_ini);
@@ -1786,7 +1789,10 @@ PHP_FUNCTION(php_strip_whitespace)
Z_PARAM_PATH_STR(filename)
ZEND_PARSE_PARAMETERS_END();
php_output_start_default();
if (UNEXPECTED(php_output_start_default() != SUCCESS)) {
zend_throw_error(NULL, "Unable to start output handler");
RETURN_THROWS();
}
zend_stream_init_filename_ex(&file_handle, filename);
zend_save_lexical_state(&original_lex_state);
@@ -1823,7 +1829,10 @@ PHP_FUNCTION(highlight_string)
ZEND_PARSE_PARAMETERS_END();
if (i) {
php_output_start_default();
if (UNEXPECTED(php_output_start_default() != SUCCESS)) {
zend_throw_error(NULL, "Unable to start output handler");
RETURN_THROWS();
}
}
EG(error_reporting) = E_ERROR;

View File

@@ -0,0 +1,25 @@
--TEST--
GH-20906 (Assertion failure when messing up output buffers) - php_strip_whitespace
--CREDITS--
vi3tL0u1s
--FILE--
<?php
class A {
function __destruct() {
php_strip_whitespace(__FILE__);
echo "x";
$c = new A;
ob_start(function () use ($c) { return '/'; }, 1);
ob_start(function () use (&$c) { $c = new A; return '/'; }, 1);
}
}
try {
new A;
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), "\n";
}
?>
--EXPECTF--
%a
Fatal error: php_strip_whitespace(): Cannot use output buffering in output buffering display handlers in %s on line %d

View File

@@ -0,0 +1,21 @@
--TEST--
GH-20906 (Assertion failure when messing up output buffers) - highlight_file
--CREDITS--
vi3tL0u1s
--FILE--
<?php
class A {
function __destruct() {
highlight_file(__FILE__, true);
echo "x";
$c = new A;
ob_start(function () use ($c) { return '/'; }, 1);
ob_start(function () use (&$c) { $c = new A; return '/'; }, 1);
}
}
new A;
?>
--EXPECTF--
%a
Fatal error: highlight_file(): Cannot use output buffering in output buffering display handlers in %s on line %d

View File

@@ -0,0 +1,21 @@
--TEST--
GH-20906 (Assertion failure when messing up output buffers) - highlight_string
--CREDITS--
vi3tL0u1s
--FILE--
<?php
class A {
function __destruct() {
highlight_string(__FILE__, true);
echo "x";
$c = new A;
ob_start(function () use ($c) { return '/'; }, 1);
ob_start(function () use (&$c) { $c = new A; return '/'; }, 1);
}
}
new A;
?>
--EXPECTF--
%a
Fatal error: highlight_string(): Cannot use output buffering in output buffering display handlers in %s on line %d