From fcc0fdd125fdb9e1713f91d027fe07d680a0cf36 Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Wed, 17 Sep 2008 00:20:30 +0000 Subject: [PATCH] Fixed bug #45392 (ob_start()/ob_end_clean() and memory_limit). --- NEWS | 1 + main/main.c | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 7f685aee20..2c43d5978a 100644 --- a/NEWS +++ b/NEWS @@ -19,6 +19,7 @@ PHP NEWS - Fixed bug #45928 (large scripts from stdin are stripped at 16K border). (Christian Schneider, Arnaud) - Fixed bug #45911 (Cannot disable ext/hash). (Arnaud) +- Fixed bug #45392 (ob_start()/ob_end_clean() and memory_limit). (Ilia) - Fixed bug #45382 (timeout bug in stream_socket_enable_crypto). (vnegrier at optilian dot com, Ilia diff --git a/main/main.c b/main/main.c index 241cedb799..1c9394c475 100644 --- a/main/main.c +++ b/main/main.c @@ -1478,7 +1478,12 @@ void php_request_shutdown(void *dummy) /* 3. Flush all output buffers */ zend_try { - php_end_ob_buffers((zend_bool)(SG(request_info).headers_only?0:1) TSRMLS_CC); + zend_bool send_buffer = SG(request_info).headers_only ? 0 : 1; + if (CG(unclean_shutdown) && PG(last_error_type) == E_ERROR && + !OG(active_ob_buffer).chunk_size && PG(memory_limit) < zend_memory_usage(1 TSRMLS_CC)) { + send_buffer = 0; + } + php_end_ob_buffers(send_buffer TSRMLS_CC); } zend_end_try(); /* 4. Send the set HTTP headers (note: This must be done AFTER php_end_ob_buffers() !!) */ -- 2.40.0