From ed8aab4d85c082d19d6c3ef7a8f0e13a00601ebd Mon Sep 17 00:00:00 2001 From: Glenn Randers-Pehrson Date: Thu, 31 Mar 2011 21:33:39 -0500 Subject: [PATCH] [devel] Free zstream memory with deflateEnd before reinitializing it. --- pngwutil.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pngwutil.c b/pngwutil.c index 44ef005b4..de99afc36 100644 --- a/pngwutil.c +++ b/pngwutil.c @@ -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);