Skip to content

Commit 4c1e2bb

Browse files
committed
Re-fix bug #55544
1 parent 2abc4c2 commit 4c1e2bb

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

ext/zlib/php_zlib.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ ZEND_BEGIN_MODULE_GLOBALS(zlib)
5555
long output_compression_default;
5656
char *output_handler;
5757
php_zlib_context *ob_gzhandler;
58+
zend_bool handler_registered;
5859
ZEND_END_MODULE_GLOBALS(zlib);
5960

6061
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);

ext/zlib/tests/bug55544.phpt

361 Bytes
Binary file not shown.

ext/zlib/zlib.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,8 @@ static php_output_handler *php_zlib_output_handler_init(const char *handler_name
263263
ZLIBG(output_compression) = chunk_size ? chunk_size : PHP_OUTPUT_HANDLER_DEFAULT_SIZE;
264264
}
265265

266+
ZLIBG(handler_registered) = 1;
267+
266268
if ((h = php_output_handler_create_internal(handler_name, handler_name_len, php_zlib_output_handler, chunk_size, flags TSRMLS_CC))) {
267269
php_output_handler_set_context(h, php_zlib_output_handler_context_init(TSRMLS_C), php_zlib_output_handler_context_dtor TSRMLS_CC);
268270
}
@@ -964,9 +966,10 @@ static PHP_MSHUTDOWN_FUNCTION(zlib)
964966
static PHP_RINIT_FUNCTION(zlib)
965967
{
966968
ZLIBG(compression_coding) = 0;
967-
ZLIBG(output_compression) = ZLIBG(output_compression_default);
968-
969-
php_zlib_output_compression_start(TSRMLS_C);
969+
if (!ZLIBG(handler_registered)) {
970+
ZLIBG(output_compression) = ZLIBG(output_compression_default);
971+
php_zlib_output_compression_start(TSRMLS_C);
972+
}
970973

971974
return SUCCESS;
972975
}
@@ -976,6 +979,7 @@ static PHP_RINIT_FUNCTION(zlib)
976979
static PHP_RSHUTDOWN_FUNCTION(zlib)
977980
{
978981
php_zlib_cleanup_ob_gzhandler_mess(TSRMLS_C);
982+
ZLIBG(handler_registered) = 0;
979983

980984
return SUCCESS;
981985
}
@@ -1000,6 +1004,7 @@ static PHP_MINFO_FUNCTION(zlib)
10001004
static ZEND_MODULE_GLOBALS_CTOR_D(zlib)
10011005
{
10021006
zlib_globals->ob_gzhandler = NULL;
1007+
zlib_globals->handler_registered = 0;
10031008
}
10041009
/* }}} */
10051010

0 commit comments

Comments
 (0)