]> granicus.if.org Git - php/commitdiff
MFH: Fixed bug #45392 (ob_start()/ob_end_clean() and memory_limit).
authorArnaud Le Blanc <lbarnaud@php.net>
Mon, 18 Aug 2008 04:09:38 +0000 (04:09 +0000)
committerArnaud Le Blanc <lbarnaud@php.net>
Mon, 18 Aug 2008 04:09:38 +0000 (04:09 +0000)
NEWS
main/output.c
tests/lang/bug45392.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index fa0095face59641e1fd9d3a92d0cf822ebb709d3..0e71605cdf00edb3980b19209cdcf1318a337cc5 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -43,6 +43,7 @@ PHP                                                                        NEWS
   before shutdown) (basant dot kukreja at sun dot com)
 - Fixed bug #45406 (session.serialize_handler declared by shared extension 
   fails). (Kalle, oleg dot grenrus at dynamoid dot com)
+- Fixed bug #45392 (ob_start()/ob_end_clean() and memory_limit). (Arnaud)
 - Fixed bug #45352 (Segmentation fault because of tick function on second
   request). (Dmitry)
 - Fixed bug #45312 (Segmentation fault on second request for array functions).
index 0b86131939317acf297bdbfbdfd7e3b4d63d7cda..4b1aa37cb16a879dfb9a010f27e16b017d4f3ce3 100644 (file)
@@ -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 (file)
index 0000000..0962a9f
--- /dev/null
@@ -0,0 +1,22 @@
+--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