Skip to content

Commit 262d2df

Browse files
Fix GH-15496: Fix accessing NULL pointer on output handler stack
1 parent 07e1a7b commit 262d2df

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

ext/standard/tests/gh15496_original_reproducer.phpt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ while (1) {
4949
}
5050
?>
5151
--EXPECTF--
52-
Fatal error: {closure%A}(): Cannot use output buffering in output buffering display handlers in %s on line %d
52+
Notice: ob_start(): Failed to create buffer in %s on line %d
53+
54+
Fatal error: Allowed memory size of %d bytes exhausted at %s (tried to allocate %d bytes) in %s on line %d
5355

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

main/output.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,8 @@ PHPAPI int php_output_handler_start(php_output_handler *handler)
538538
if (php_output_lock_error(PHP_OUTPUT_HANDLER_START) || !handler) {
539539
return FAILURE;
540540
}
541-
if (!(OG(flags) & PHP_OUTPUT_ACTIVATED) || !OG(handlers).elements) {
541+
/* Output activated but stack destroyed */
542+
if ((OG(flags) & PHP_OUTPUT_ACTIVATED) && OG(handlers).elements == NULL) {
542543
return FAILURE;
543544
}
544545
if (NULL != (conflict = zend_hash_find_ptr(&php_output_handler_conflicts, handler->name))) {

0 commit comments

Comments
 (0)