Skip to content

Commit abd2b2e

Browse files
reezeyohgaki
authored andcommitted
- fix bug #61541, Segfault when using ob_* in output_callback
1 parent 5ddfdb8 commit abd2b2e

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

main/output.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,17 @@ PHPAPI void php_end_ob_buffer(zend_bool send_buffer, zend_bool just_flush TSRMLS
225225
zval *orig_buffer;
226226
zval *z_status;
227227

228+
if(OG(ob_lock)) {
229+
if (SG(headers_sent) && !SG(request_info).headers_only) {
230+
OG(php_body_write) = php_ub_body_write_no_header;
231+
} else {
232+
OG(php_body_write) = php_ub_body_write;
233+
}
234+
OG(ob_nesting_level) = 0;
235+
php_error_docref("ref.outcontrol" TSRMLS_CC, E_ERROR, "Cannot use output buffering in output buffering display handlers");
236+
return;
237+
}
238+
228239
ALLOC_INIT_ZVAL(orig_buffer);
229240
ZVAL_STRINGL(orig_buffer, OG(active_ob_buffer).buffer, OG(active_ob_buffer).text_length, 1);
230241

tests/output/ob_011.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
--TEST--
22
output buffering - fatalism
3-
--XFAIL--
4-
This test will fail until the fix in revision r214155 is backported from php 6
53
--FILE--
64
<?php
75
function obh($s)

0 commit comments

Comments
 (0)