mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
[devel] Re-initialize the zlib compressor before compressing non-IDAT chunks.
This commit is contained in:
21
pngmem.c
21
pngmem.c
@@ -187,8 +187,9 @@ png_malloc_default,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
||||
int num_blocks;
|
||||
png_uint_32 total_size;
|
||||
png_bytep table;
|
||||
int i;
|
||||
int i, mem_level, window_bits;
|
||||
png_byte huge * hptr;
|
||||
int window_bits
|
||||
|
||||
if (ret != NULL)
|
||||
{
|
||||
@@ -196,14 +197,22 @@ png_malloc_default,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
||||
ret = NULL;
|
||||
}
|
||||
|
||||
if (png_ptr->zlib_window_bits > 14)
|
||||
num_blocks = (int)(1 << (png_ptr->zlib_window_bits - 14));
|
||||
window_bits =
|
||||
png_ptr->zlib_window_bits >= png_ptr->zlib_text_window_bits ?
|
||||
png_ptr->zlib_window_bits : png_ptr->zlib_text_window_bits;
|
||||
|
||||
if (window_bits > 14)
|
||||
num_blocks = (int)(1 << (window_bits - 14));
|
||||
|
||||
else
|
||||
num_blocks = 1;
|
||||
|
||||
if (png_ptr->zlib_mem_level >= 7)
|
||||
num_blocks += (int)(1 << (png_ptr->zlib_mem_level - 7));
|
||||
mem_level =
|
||||
png_ptr->zlib_mem_level >= png_ptr->zlib_text_mem_level ?
|
||||
png_ptr->zlib_mem_level : png_ptr->zlib_text_mem_level;
|
||||
|
||||
if (mem_level >= 7)
|
||||
num_blocks += (int)(1 << (mem_level - 7));
|
||||
|
||||
else
|
||||
num_blocks++;
|
||||
@@ -277,7 +286,7 @@ png_malloc_default,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
||||
{
|
||||
# ifndef PNG_USER_MEM_SUPPORTED
|
||||
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
||||
png_error(png_ptr, "Out of Memory"); /* Note "o" and "M" */
|
||||
png_error(png_ptr, "Out of Memory"); /* Note "O" and "M" */
|
||||
|
||||
else
|
||||
png_warning(png_ptr, "Out of Memory");
|
||||
|
||||
Reference in New Issue
Block a user