Skip to content

Commit

Permalink
Fix bug with copying z_stream objects around in zip archiver (thanks,…
Browse files Browse the repository at this point in the history
… 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!).
  • Loading branch information
icculus committed Feb 18, 2017
1 parent da8ef23 commit 8d62a2c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion archivers/zip.c
Expand Up @@ -327,7 +327,8 @@ static int ZIP_seek(fvoid *opaque, PHYSFS_uint64 offset)
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 */

Expand Down

0 comments on commit 8d62a2c

Please sign in to comment.