diff --git a/main/output.c b/main/output.c index 6f3b4e3c5ac..59c6c8bdaf8 100644 --- a/main/output.c +++ b/main/output.c @@ -336,7 +336,13 @@ PHPAPI void php_end_ob_buffer(zend_bool send_buffer, zend_bool just_flush TSRMLS PHPAPI void php_end_ob_buffers(zend_bool send_buffer TSRMLS_DC) { while (OG(ob_nesting_level)!=0) { - php_end_ob_buffer(send_buffer, 0 TSRMLS_CC); + /* in case of unclean_shutdown, do not output the buffer if it is not + * meant to be until end of script or ob_end_*() call */ + if (CG(unclean_shutdown) && !OG(active_ob_buffer).chunk_size) { + php_end_ob_buffer(0, 0 TSRMLS_CC); + } else { + php_end_ob_buffer(send_buffer, 0 TSRMLS_CC); + } } } /* }}} */ diff --git a/tests/lang/bug45392.phpt b/tests/lang/bug45392.phpt new file mode 100644 index 00000000000..0962a9fe800 --- /dev/null +++ b/tests/lang/bug45392.phpt @@ -0,0 +1,22 @@ +--TEST-- +Bug #45392 (ob_start()/ob_end_clean() and memory_limit) +--INI-- +display_errors=stderr +--FILE-- + +--EXPECTF-- +2 +Fatal error: Allowed memory size of %d bytes exhausted%s +5