From f32760bd40aa368beeccd8ce53b425b2ebae159c Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Mon, 16 Jan 2012 17:51:35 +0000 Subject: [PATCH] Fix bug #60768 Output buffer not discarded in php_output_handler_op(): * if appending to buffer succeeds, just return HANDLER_NO_DATA and do nothing else * if a zero sized string or true is returned from the handler function, reset the context as well as the handler's buffer --- main/output.c | 11 ++++++----- tests/output/bug60768.phpt | 25 +++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 5 deletions(-) create mode 100644 tests/output/bug60768.phpt diff --git a/main/output.c b/main/output.c index 1ab4d7dbf9..4697cbfb0d 100644 --- a/main/output.c +++ b/main/output.c @@ -885,7 +885,8 @@ static inline php_output_handler_status_t php_output_handler_op(php_output_handl /* storable? */ if (php_output_handler_append(handler, &context->in TSRMLS_CC) && !context->op) { - status = PHP_OUTPUT_HANDLER_NO_DATA; + context->op = original_op; + return PHP_OUTPUT_HANDLER_NO_DATA; } else { /* need to start? */ if (!(handler->flags & PHP_OUTPUT_HANDLER_STARTED)) { @@ -961,13 +962,13 @@ static inline php_output_handler_status_t php_output_handler_op(php_output_handl handler->buffer.used = 0; handler->buffer.size = 0; break; - case PHP_OUTPUT_HANDLER_SUCCESS: - /* no more buffered data */ - handler->buffer.used = 0; - break; case PHP_OUTPUT_HANDLER_NO_DATA: /* handler ate all */ php_output_context_reset(context); + /* no break */ + case PHP_OUTPUT_HANDLER_SUCCESS: + /* no more buffered data */ + handler->buffer.used = 0; break; } diff --git a/tests/output/bug60768.phpt b/tests/output/bug60768.phpt new file mode 100644 index 0000000000..2527e8e84a --- /dev/null +++ b/tests/output/bug60768.phpt @@ -0,0 +1,25 @@ +--TEST-- +Bug #60768 Output buffer not discarded +--FILE-- + +DONE +--EXPECT-- +Output size: 120, expected 120 +DONE + -- 2.40.0