]> granicus.if.org Git - php/commitdiff
Fixes to internal output buffering
authorZeev Suraski <zeev@php.net>
Tue, 6 Mar 2001 18:29:00 +0000 (18:29 +0000)
committerZeev Suraski <zeev@php.net>
Tue, 6 Mar 2001 18:29:00 +0000 (18:29 +0000)
ext/standard/output.c
main/output.c

index 59fe87c761e1e779643024f2b6f87974fe30be61..672975f217cdbb933f8dc1a8471877d9ca4adf64 100644 (file)
@@ -122,7 +122,7 @@ PHPAPI void php_end_ob_buffer(zend_bool send_buffer, zend_bool just_flush)
        char *final_buffer=NULL;
        int final_buffer_length=0;
        zval *alternate_buffer=NULL;
-       char *to_be_destroyed_buffer;
+       char *to_be_destroyed_buffer, *to_be_destroyed_output_buffer;
        int status;
        SLS_FETCH();
        OLS_FETCH();
@@ -193,12 +193,9 @@ PHPAPI void php_end_ob_buffer(zend_bool send_buffer, zend_bool just_flush)
        }
 
        to_be_destroyed_buffer = OG(active_ob_buffer).buffer;
+       to_be_destroyed_output_buffer = OG(active_ob_buffer).internal_output_handler_buffer;
 
        if (!just_flush) {
-               if (OG(active_ob_buffer).internal_output_handler
-                       && (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;
 
@@ -222,11 +219,18 @@ PHPAPI void php_end_ob_buffer(zend_bool send_buffer, zend_bool just_flush)
        if (!just_flush) {
                efree(to_be_destroyed_buffer);
 
+               if (to_be_destroyed_output_buffer) {
+                       efree(to_be_destroyed_output_buffer);
+               }
                OG(nesting_level)--;
        } else {
                OG(active_ob_buffer).text_length = 0;
                OG(active_ob_buffer).status |= PHP_OUTPUT_HANDLER_START;
                OG(php_body_write) = php_b_body_write;
+               if (OG(active_ob_buffer).internal_output_handler
+                       && final_buffer != OG(active_ob_buffer).internal_output_handler_buffer) {
+                       efree(final_buffer);
+               }
        }
 }
 
index 59fe87c761e1e779643024f2b6f87974fe30be61..672975f217cdbb933f8dc1a8471877d9ca4adf64 100644 (file)
@@ -122,7 +122,7 @@ PHPAPI void php_end_ob_buffer(zend_bool send_buffer, zend_bool just_flush)
        char *final_buffer=NULL;
        int final_buffer_length=0;
        zval *alternate_buffer=NULL;
-       char *to_be_destroyed_buffer;
+       char *to_be_destroyed_buffer, *to_be_destroyed_output_buffer;
        int status;
        SLS_FETCH();
        OLS_FETCH();
@@ -193,12 +193,9 @@ PHPAPI void php_end_ob_buffer(zend_bool send_buffer, zend_bool just_flush)
        }
 
        to_be_destroyed_buffer = OG(active_ob_buffer).buffer;
+       to_be_destroyed_output_buffer = OG(active_ob_buffer).internal_output_handler_buffer;
 
        if (!just_flush) {
-               if (OG(active_ob_buffer).internal_output_handler
-                       && (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;
 
@@ -222,11 +219,18 @@ PHPAPI void php_end_ob_buffer(zend_bool send_buffer, zend_bool just_flush)
        if (!just_flush) {
                efree(to_be_destroyed_buffer);
 
+               if (to_be_destroyed_output_buffer) {
+                       efree(to_be_destroyed_output_buffer);
+               }
                OG(nesting_level)--;
        } else {
                OG(active_ob_buffer).text_length = 0;
                OG(active_ob_buffer).status |= PHP_OUTPUT_HANDLER_START;
                OG(php_body_write) = php_b_body_write;
+               if (OG(active_ob_buffer).internal_output_handler
+                       && final_buffer != OG(active_ob_buffer).internal_output_handler_buffer) {
+                       efree(final_buffer);
+               }
        }
 }