]> granicus.if.org Git - php/commitdiff
Re-fix bug #55544
authorXinchen Hui <laruence@php.net>
Tue, 24 Jul 2012 06:43:53 +0000 (14:43 +0800)
committerXinchen Hui <laruence@php.net>
Tue, 24 Jul 2012 06:43:53 +0000 (14:43 +0800)
ext/zlib/php_zlib.h
ext/zlib/tests/bug55544.phpt [new file with mode: 0644]
ext/zlib/zlib.c

index 449dfed0620f6f388dd706a9ab56f59d0bf80c46..ab673512fcde29265afc13584646fc33b8078658 100644 (file)
@@ -55,6 +55,7 @@ ZEND_BEGIN_MODULE_GLOBALS(zlib)
        long output_compression_default;
        char *output_handler;
        php_zlib_context *ob_gzhandler;
+    zend_bool handler_registered;
 ZEND_END_MODULE_GLOBALS(zlib);
 
 php_stream *php_stream_gzopen(php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC);
diff --git a/ext/zlib/tests/bug55544.phpt b/ext/zlib/tests/bug55544.phpt
new file mode 100644 (file)
index 0000000..ca4214a
Binary files /dev/null and b/ext/zlib/tests/bug55544.phpt differ
index eac757bbc58d08d0dae212fba179a07c6cd9633e..7ff2b30c4c4e7911634dfad522bff26754f0cc2c 100644 (file)
@@ -263,6 +263,8 @@ static php_output_handler *php_zlib_output_handler_init(const char *handler_name
                ZLIBG(output_compression) = chunk_size ? chunk_size : PHP_OUTPUT_HANDLER_DEFAULT_SIZE;
        }
 
+    ZLIBG(handler_registered) = 1;
+
        if ((h = php_output_handler_create_internal(handler_name, handler_name_len, php_zlib_output_handler, chunk_size, flags TSRMLS_CC))) {
                php_output_handler_set_context(h, php_zlib_output_handler_context_init(TSRMLS_C), php_zlib_output_handler_context_dtor TSRMLS_CC);
        }
@@ -964,9 +966,10 @@ static PHP_MSHUTDOWN_FUNCTION(zlib)
 static PHP_RINIT_FUNCTION(zlib)
 {
        ZLIBG(compression_coding) = 0;
-       ZLIBG(output_compression) = ZLIBG(output_compression_default);
-
-       php_zlib_output_compression_start(TSRMLS_C);
+    if (!ZLIBG(handler_registered)) {
+        ZLIBG(output_compression) = ZLIBG(output_compression_default);
+        php_zlib_output_compression_start(TSRMLS_C);
+    }
 
        return SUCCESS;
 }
@@ -976,6 +979,7 @@ static PHP_RINIT_FUNCTION(zlib)
 static PHP_RSHUTDOWN_FUNCTION(zlib)
 {
        php_zlib_cleanup_ob_gzhandler_mess(TSRMLS_C);
+    ZLIBG(handler_registered) = 0;
 
     return SUCCESS;
 }
@@ -1000,6 +1004,7 @@ static PHP_MINFO_FUNCTION(zlib)
 static ZEND_MODULE_GLOBALS_CTOR_D(zlib)
 {
        zlib_globals->ob_gzhandler = NULL;
+    zlib_globals->handler_registered = 0;
 }
 /* }}} */