From: Zeev Suraski Date: Tue, 6 Mar 2001 16:28:51 +0000 (+0000) Subject: More internal output buffering fixes X-Git-Tag: php-4.0.5RC1~69 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0ece429a163b696b04064f2b7832178edd49ed6f;p=php More internal output buffering fixes --- diff --git a/ext/standard/output.c b/ext/standard/output.c index 6055439725..59fe87c761 100644 --- a/ext/standard/output.c +++ b/ext/standard/output.c @@ -123,7 +123,6 @@ PHPAPI void php_end_ob_buffer(zend_bool send_buffer, zend_bool just_flush) int final_buffer_length=0; zval *alternate_buffer=NULL; char *to_be_destroyed_buffer; - char *internal_output_handler_buffer; int status; SLS_FETCH(); OLS_FETCH(); @@ -143,8 +142,9 @@ PHPAPI void php_end_ob_buffer(zend_bool send_buffer, zend_bool just_flush) } if (OG(active_ob_buffer).internal_output_handler) { - internal_output_handler_buffer = OG(active_ob_buffer).internal_output_handler_buffer; - OG(active_ob_buffer).internal_output_handler(OG(active_ob_buffer).buffer, OG(active_ob_buffer).text_length, &internal_output_handler_buffer, status); + final_buffer = OG(active_ob_buffer).internal_output_handler_buffer; + final_buffer_length = OG(active_ob_buffer).internal_output_handler_buffer_size; + OG(active_ob_buffer).internal_output_handler(OG(active_ob_buffer).buffer, OG(active_ob_buffer).text_length, &final_buffer, &final_buffer_length, status); } else if (OG(active_ob_buffer).output_handler) { zval **params[2]; zval *orig_buffer; @@ -196,8 +196,8 @@ PHPAPI void php_end_ob_buffer(zend_bool send_buffer, zend_bool just_flush) if (!just_flush) { if (OG(active_ob_buffer).internal_output_handler - && (internal_output_handler_buffer != OG(active_ob_buffer).internal_output_handler_buffer)) { - efree(internal_output_handler_buffer); + && (final_buffer != OG(active_ob_buffer).internal_output_handler_buffer)) { + efree(final_buffer); } if (OG(nesting_level)>1) { /* restore previous buffer */ php_ob_buffer *ob_buffer_p; diff --git a/ext/standard/php_output.h b/ext/standard/php_output.h index 3bfd5d078c..39bb8954b2 100644 --- a/ext/standard/php_output.h +++ b/ext/standard/php_output.h @@ -23,7 +23,7 @@ #include "php.h" -typedef void (*php_output_handler_func_t)(char *output, uint output_len, char **handled_output, int mode); +typedef void (*php_output_handler_func_t)(char *output, uint output_len, char **handled_output, uint *handled_output_len, int mode); PHPAPI void php_output_startup(void); void php_output_register_constants(void); diff --git a/main/output.c b/main/output.c index 6055439725..59fe87c761 100644 --- a/main/output.c +++ b/main/output.c @@ -123,7 +123,6 @@ PHPAPI void php_end_ob_buffer(zend_bool send_buffer, zend_bool just_flush) int final_buffer_length=0; zval *alternate_buffer=NULL; char *to_be_destroyed_buffer; - char *internal_output_handler_buffer; int status; SLS_FETCH(); OLS_FETCH(); @@ -143,8 +142,9 @@ PHPAPI void php_end_ob_buffer(zend_bool send_buffer, zend_bool just_flush) } if (OG(active_ob_buffer).internal_output_handler) { - internal_output_handler_buffer = OG(active_ob_buffer).internal_output_handler_buffer; - OG(active_ob_buffer).internal_output_handler(OG(active_ob_buffer).buffer, OG(active_ob_buffer).text_length, &internal_output_handler_buffer, status); + final_buffer = OG(active_ob_buffer).internal_output_handler_buffer; + final_buffer_length = OG(active_ob_buffer).internal_output_handler_buffer_size; + OG(active_ob_buffer).internal_output_handler(OG(active_ob_buffer).buffer, OG(active_ob_buffer).text_length, &final_buffer, &final_buffer_length, status); } else if (OG(active_ob_buffer).output_handler) { zval **params[2]; zval *orig_buffer; @@ -196,8 +196,8 @@ PHPAPI void php_end_ob_buffer(zend_bool send_buffer, zend_bool just_flush) if (!just_flush) { if (OG(active_ob_buffer).internal_output_handler - && (internal_output_handler_buffer != OG(active_ob_buffer).internal_output_handler_buffer)) { - efree(internal_output_handler_buffer); + && (final_buffer != OG(active_ob_buffer).internal_output_handler_buffer)) { + efree(final_buffer); } if (OG(nesting_level)>1) { /* restore previous buffer */ php_ob_buffer *ob_buffer_p; diff --git a/main/php_output.h b/main/php_output.h index 3bfd5d078c..39bb8954b2 100644 --- a/main/php_output.h +++ b/main/php_output.h @@ -23,7 +23,7 @@ #include "php.h" -typedef void (*php_output_handler_func_t)(char *output, uint output_len, char **handled_output, int mode); +typedef void (*php_output_handler_func_t)(char *output, uint output_len, char **handled_output, uint *handled_output_len, int mode); PHPAPI void php_output_startup(void); void php_output_register_constants(void);