diff --git a/ext/standard/tests/gh15496_original_reproducer.phpt b/ext/standard/tests/gh15496_original_reproducer.phpt new file mode 100644 index 0000000000000..c799a099f5c2c --- /dev/null +++ b/ext/standard/tests/gh15496_original_reproducer.phpt @@ -0,0 +1,54 @@ +--TEST-- +GH-15496: Session handler ob_start crash +--FILE-- + +--EXPECTF-- +Fatal error: {closure%A}(): 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 diff --git a/main/output.c b/main/output.c index c2cb0ceab0112..24dca751d98d3 100644 --- a/main/output.c +++ b/main/output.c @@ -538,6 +538,9 @@ PHPAPI int php_output_handler_start(php_output_handler *handler) if (php_output_lock_error(PHP_OUTPUT_HANDLER_START) || !handler) { return FAILURE; } + if (!(OG(flags) & PHP_OUTPUT_ACTIVATED)) { + return FAILURE; + } if (NULL != (conflict = zend_hash_find_ptr(&php_output_handler_conflicts, handler->name))) { if (SUCCESS != conflict(ZSTR_VAL(handler->name), ZSTR_LEN(handler->name))) { return FAILURE;