mirror of
https://github.com/php/php-src.git
synced 2024-11-27 11:53:33 +08:00
MFH: Avoid leaks when zlib streams can not be closed properly.
This commit is contained in:
parent
98b5795702
commit
93b7cb0a0a
@ -218,6 +218,19 @@ zend_module_entry php_zlib_module_entry = {
|
||||
ZEND_GET_MODULE(php_zlib)
|
||||
#endif
|
||||
|
||||
/* {{{ Memory management wrappers */
|
||||
|
||||
static voidpf php_zlib_alloc(voidpf opaque, uInt items, uInt size)
|
||||
{
|
||||
return (voidpf)safe_emalloc(items, size, 0);
|
||||
}
|
||||
|
||||
static void php_zlib_free(voidpf opaque, voidpf address)
|
||||
{
|
||||
efree((void*)address);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ OnUpdate_zlib_output_compression */
|
||||
static PHP_INI_MH(OnUpdate_zlib_output_compression)
|
||||
{
|
||||
@ -553,8 +566,8 @@ static PHP_FUNCTION(gzdeflate)
|
||||
}
|
||||
|
||||
stream.data_type = Z_ASCII;
|
||||
stream.zalloc = (alloc_func) Z_NULL;
|
||||
stream.zfree = (free_func) Z_NULL;
|
||||
stream.zalloc = php_zlib_alloc;
|
||||
stream.zfree = php_zlib_free;
|
||||
stream.opaque = (voidpf) Z_NULL;
|
||||
|
||||
stream.next_in = (Bytef *) data;
|
||||
@ -620,8 +633,8 @@ static PHP_FUNCTION(gzinflate)
|
||||
}
|
||||
plength = limit;
|
||||
|
||||
stream.zalloc = (alloc_func) Z_NULL;
|
||||
stream.zfree = (free_func) Z_NULL;
|
||||
stream.zalloc = php_zlib_alloc;
|
||||
stream.zfree = php_zlib_free;
|
||||
stream.opaque = Z_NULL;
|
||||
stream.avail_in = data_len + 1; /* there is room for \0 */
|
||||
stream.next_in = (Bytef *) data;
|
||||
@ -746,8 +759,8 @@ static int php_deflate_string(const char *str, uint str_length, char **newstr, u
|
||||
int err;
|
||||
|
||||
if (do_start) {
|
||||
ZLIBG(stream).zalloc = Z_NULL;
|
||||
ZLIBG(stream).zfree = Z_NULL;
|
||||
ZLIBG(stream).zalloc = php_zlib_alloc;
|
||||
ZLIBG(stream).zfree = php_zlib_free;
|
||||
ZLIBG(stream).opaque = Z_NULL;
|
||||
|
||||
switch (ZLIBG(compression_coding)) {
|
||||
@ -836,8 +849,8 @@ static PHP_FUNCTION(gzencode)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
stream.zalloc = Z_NULL;
|
||||
stream.zfree = Z_NULL;
|
||||
stream.zalloc = php_zlib_alloc;
|
||||
stream.zfree = php_zlib_free;
|
||||
stream.opaque = Z_NULL;
|
||||
|
||||
stream.next_in = (Bytef *) data;
|
||||
|
Loading…
Reference in New Issue
Block a user