Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions main/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,10 @@ PHPAPI zend_result php_output_handler_start(php_output_handler *handler)
HashTable *rconflicts;
php_output_handler_conflict_check_t conflict;

if (!(OG(flags) & PHP_OUTPUT_ACTIVATED)) {
return FAILURE;
}

if (php_output_lock_error(PHP_OUTPUT_HANDLER_START) || !handler) {
return FAILURE;
}
Expand Down
3 changes: 3 additions & 0 deletions tests/output/gh20352.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@ ob_start(new Test, 1);
echo "trigger bug";
?>
--EXPECTF--
%r(Notice: ob_start\(\): Failed to create buffer in [^\r\n]+ on line \d+\r?\n(\r?\n)?)+%r
Notice: ob_start(): Failed to create buffer in %s on line %d

Fatal error: ob_start(): Cannot use output buffering in output buffering display handlers in %s on line %d
23 changes: 23 additions & 0 deletions tests/output/gh20837.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
--TEST--
ob_start(): NULL dereference when calling ob_start() in shutdown function triggered by bailout in php_output_lock_error()
--FILE--
<?php

register_shutdown_function(function () {
ob_start(function ($input) {
echo "bar";
return strtoupper($input);
});
});

ob_start(function () {
ob_start();
}, 1);

echo "foo";

?>
--EXPECTF--
Fatal error: ob_start(): Cannot use output buffering in output buffering display handlers in %s on line %d

Notice: ob_start(): Failed to create buffer in %s on line %d