Fix bug with copying z_stream objects around in zip archiver (thanks, Andrei!). stable-1.0
authorRyan C. Gordon <icculus@icculus.org>
Fri, 17 Feb 2017 20:48:02 -0500
branchstable-1.0
changeset 1390 60449ca1b00a
parent 1388 cbeb7bee829f
Fix bug with copying z_stream objects around in zip archiver (thanks, Andrei!).

zlib expects us to use inflateCopy() to move a z_stream, then inflateEnd()
the original, and apparently fails in later versions if you just try to
memcpy() it.

This is only a bug in the stable-2.0 and stable-1.0 branches; we replaced
zlib with miniz on the development branch, which doesn't have this
requirement (or an inflateCopy() function at all!).
(transplanted from 090cb9c74b87198e6d520afca9d649ca0d84669f)
archivers/zip.c
--- a/archivers/zip.c	Fri Feb 17 20:43:27 2017 -0500
+++ b/archivers/zip.c	Fri Feb 17 20:48:02 2017 -0500
@@ -368,7 +368,8 @@
                 return(0);
 
             inflateEnd(&finfo->stream);
-            memcpy(&finfo->stream, &str, sizeof (z_stream));
+            inflateCopy(&finfo->stream, &str);
+            inflateEnd(&str);
             finfo->uncompressed_position = finfo->compressed_position = 0;
         } /* if */