--- libmng_zlib.c	2005-12-15 01:53:13.000000000 +0200
+++ libmng_zlib.c	2007-08-01 13:24:11.000000000 +0300
@@ -162,6 +162,8 @@
 #ifdef MNG_SUPPORT_TRACE
   MNG_TRACE (pData, MNG_FN_ZLIB_INFLATEINIT, MNG_LC_START);
 #endif
+  if ( pData->bInflating )
+    inflateEnd( &pData->sZlib );
                                        /* initialize zlib structures and such */
   iZrslt = inflateInit (&pData->sZlib);
 
