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);
+ }
}
}
/* }}} */
--- /dev/null
+--TEST--
+Bug #45392 (ob_start()/ob_end_clean() and memory_limit)
+--INI--
+display_errors=stderr
+--FILE--
+<?php
+echo __LINE__ . "\n";
+ini_set('memory_limit', 100);
+ob_start(NULL, 10);
+echo __LINE__ ."\n";
+ob_start();
+$i = 0;
+while($i++ < 5000) {
+ echo str_repeat("may not be displayed ", 42);
+}
+ob_end_flush();
+ob_end_clean();
+?>
+--EXPECTF--
+2
+Fatal error: Allowed memory size of %d bytes exhausted%s
+5