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

index 5a2b8641d39a2e440a4f0645f5b3c0cf8c1d2aee..89987f57a691ebecacf88b1fe0ed5fe9ccf4944a 100644 (file)
@@ -1275,7 +1275,11 @@ static inline int php_output_stack_pop(int flags TSRMLS_DC)
                
                /* pass output along */
                if (context.out.data && context.out.used && !(flags & PHP_OUTPUT_POP_DISCARD)) {
-                       php_output_write(context.out.data, context.out.used 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) || orphan->size) {
+                               php_output_write(context.out.data, context.out.used TSRMLS_CC);
+                       }
                }
                
                /* destroy the handler (after write!) */
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