[devel] Free zstream memory with deflateEnd before reinitializing it.

This commit is contained in:
Glenn Randers-Pehrson 2011-03-31 21:33:39 -05:00
parent 6bdea98992
commit ed8aab4d85

View File

@ -678,6 +678,8 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
png_ptr->zlib_text_method = 8;
#endif /* PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION */
/* Free memory from previously opened zstream */
deflateEnd(&png_ptr->zstream);
/* Initialize the zlib compressor */
ret = deflateInit2(&png_ptr->zstream, png_ptr->zlib_level,
png_ptr->zlib_method, png_ptr->zlib_window_bits,
@ -776,6 +778,9 @@ png_write_IDAT(png_structp png_ptr, png_bytep data, png_size_t length)
int ret;
unsigned int z_cmf; /* zlib compression method and flags */
/* Free memory from previously opened zstream */
deflateEnd(&png_ptr->zstream);
ret = deflateInit2(&png_ptr->zstream, png_ptr->zlib_level,
png_ptr->zlib_method, png_ptr->zlib_window_bits,
png_ptr->zlib_mem_level, png_ptr->zlib_strategy);