Skip to content

Commit 225af96

Browse files
committed
Fixed bug #65593 (Segfault when calling ob_start from output buffering callback)
1 parent 73c2e91 commit 225af96

File tree

3 files changed

+27
-11
lines changed

3 files changed

+27
-11
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ PHP NEWS
33
?? ??? 2015, PHP 5.5.23
44

55
- Core:
6+
. Fixed bug #65593 (Segfault when calling ob_start from output buffering
7+
callback). (Mike)
68
. Fixed bug #69017 (Fail to push to the empty array with the constant value
79
defined in class scope). (Laruence)
810
. Added NULL byte protection to exec, system and passthru. (Yasuo)

main/output.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -172,21 +172,22 @@ PHPAPI void php_output_deactivate(TSRMLS_D)
172172
{
173173
php_output_handler **handler = NULL;
174174

175-
php_output_header(TSRMLS_C);
175+
if ((OG(flags) & PHP_OUTPUT_ACTIVATED)) {
176+
php_output_header(TSRMLS_C);
176177

177-
OG(flags) ^= PHP_OUTPUT_ACTIVATED;
178-
OG(active) = NULL;
179-
OG(running) = NULL;
178+
OG(flags) ^= PHP_OUTPUT_ACTIVATED;
179+
OG(active) = NULL;
180+
OG(running) = NULL;
180181

181-
/* release all output handlers */
182-
if (OG(handlers).elements) {
183-
while (SUCCESS == zend_stack_top(&OG(handlers), (void *) &handler)) {
184-
php_output_handler_free(handler TSRMLS_CC);
185-
zend_stack_del_top(&OG(handlers));
182+
/* release all output handlers */
183+
if (OG(handlers).elements) {
184+
while (SUCCESS == zend_stack_top(&OG(handlers), (void *) &handler)) {
185+
php_output_handler_free(handler TSRMLS_CC);
186+
zend_stack_del_top(&OG(handlers));
187+
}
188+
zend_stack_destroy(&OG(handlers));
186189
}
187-
zend_stack_destroy(&OG(handlers));
188190
}
189-
190191
}
191192
/* }}} */
192193

tests/output/bug65593.phpt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--TEST--
2+
Bug #65593 (ob_start(function(){ob_start();});)
3+
--FILE--
4+
<?php
5+
echo "Test\n";
6+
7+
ob_start(function(){ob_start();});
8+
?>
9+
===DONE===
10+
--EXPECT--
11+
Test
12+
13+
Fatal error: Cannot destroy active lambda function in /home/mike/src/php-5.5/tests/output/bug65593.php on line 4

0 commit comments

Comments
 (0)