Skip to content

Commit fcc0fdd

Browse files
author
Ilia Alshanetsky
committed
Fixed bug #45392 (ob_start()/ob_end_clean() and memory_limit).
1 parent 2c98da2 commit fcc0fdd

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ PHP NEWS
1919
- Fixed bug #45928 (large scripts from stdin are stripped at 16K border).
2020
(Christian Schneider, Arnaud)
2121
- Fixed bug #45911 (Cannot disable ext/hash). (Arnaud)
22+
- Fixed bug #45392 (ob_start()/ob_end_clean() and memory_limit). (Ilia)
2223
- Fixed bug #45382 (timeout bug in stream_socket_enable_crypto).
2324
(vnegrier at optilian dot com, Ilia
2425

main/main.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1478,7 +1478,12 @@ void php_request_shutdown(void *dummy)
14781478

14791479
/* 3. Flush all output buffers */
14801480
zend_try {
1481-
php_end_ob_buffers((zend_bool)(SG(request_info).headers_only?0:1) TSRMLS_CC);
1481+
zend_bool send_buffer = SG(request_info).headers_only ? 0 : 1;
1482+
if (CG(unclean_shutdown) && PG(last_error_type) == E_ERROR &&
1483+
!OG(active_ob_buffer).chunk_size && PG(memory_limit) < zend_memory_usage(1 TSRMLS_CC)) {
1484+
send_buffer = 0;
1485+
}
1486+
php_end_ob_buffers(send_buffer TSRMLS_CC);
14821487
} zend_end_try();
14831488

14841489
/* 4. Send the set HTTP headers (note: This must be done AFTER php_end_ob_buffers() !!) */

0 commit comments

Comments
 (0)