Skip to content

Commit 1f33902

Browse files
committed
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4: output: Fail starting to output buffer when the output layer is deactivated (#20846)
2 parents 750c220 + b5d6377 commit 1f33902

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ PHP NEWS
77
(henderkes)
88
. Fixed bug GH-20767 (build failure with musttail/preserve_none feature
99
on macOs). (David Carlier)
10+
. Fixed bug GH-20837 (NULL dereference when calling ob_start() in shutdown
11+
function triggered by bailout in php_output_lock_error()). (timwolla)
1012

1113
- MbString:
1214
. Fixed bug GH-20833 (mb_str_pad() divide by zero if padding string is

main/output.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,10 @@ PHPAPI zend_result php_output_handler_start(php_output_handler *handler)
538538
HashTable *rconflicts;
539539
php_output_handler_conflict_check_t conflict;
540540

541+
if (!(OG(flags) & PHP_OUTPUT_ACTIVATED)) {
542+
return FAILURE;
543+
}
544+
541545
if (php_output_lock_error(PHP_OUTPUT_HANDLER_START) || !handler) {
542546
return FAILURE;
543547
}

tests/output/gh20352.phpt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,7 @@ ob_start(new Test, 1);
2121
echo "trigger bug";
2222
?>
2323
--EXPECTF--
24+
%r(Notice: ob_start\(\): Failed to create buffer in [^\r\n]+ on line \d+\r?\n(\r?\n)?)+%r
25+
Notice: ob_start(): Failed to create buffer in %s on line %d
26+
2427
Fatal error: ob_start(): Cannot use output buffering in output buffering display handlers in %s on line %d

tests/output/gh20837.phpt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
ob_start(): NULL dereference when calling ob_start() in shutdown function triggered by bailout in php_output_lock_error()
3+
--FILE--
4+
<?php
5+
6+
register_shutdown_function(function () {
7+
ob_start(function ($input) {
8+
echo "bar";
9+
return strtoupper($input);
10+
});
11+
});
12+
13+
ob_start(function () {
14+
ob_start();
15+
}, 1);
16+
17+
echo "foo";
18+
19+
?>
20+
--EXPECTF--
21+
Fatal error: ob_start(): Cannot use output buffering in output buffering display handlers in %s on line %d
22+
23+
Notice: ob_start(): Failed to create buffer in %s on line %d

0 commit comments

Comments
 (0)