From 1aef6c9dd830204e7c4f7450ceb3cee1c249bfa7 Mon Sep 17 00:00:00 2001 From: BlackMATov Date: Mon, 20 Apr 2020 15:45:40 +0700 Subject: [PATCH] update miniz to latest master --- modules/miniz | 2 +- sources/3rdparty/miniz/miniz.c | 13 +++++++++---- sources/3rdparty/miniz/miniz.h | 2 ++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/modules/miniz b/modules/miniz index e48d8bab..4159f8c8 160000 --- a/modules/miniz +++ b/modules/miniz @@ -1 +1 @@ -Subproject commit e48d8bab887deeddb608d713128529c9261bf9e7 +Subproject commit 4159f8c8c3d91a76648107ce6adf54bb6f06e3a7 diff --git a/sources/3rdparty/miniz/miniz.c b/sources/3rdparty/miniz/miniz.c index 696f8a2e..bfc234af 100644 --- a/sources/3rdparty/miniz/miniz.c +++ b/sources/3rdparty/miniz/miniz.c @@ -552,19 +552,18 @@ int mz_inflateEnd(mz_streamp pStream) } return MZ_OK; } - -int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len) +int mz_uncompress2(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong *pSource_len) { mz_stream stream; int status; memset(&stream, 0, sizeof(stream)); /* In case mz_ulong is 64-bits (argh I hate longs). */ - if ((source_len | *pDest_len) > 0xFFFFFFFFU) + if ((*pSource_len | *pDest_len) > 0xFFFFFFFFU) return MZ_PARAM_ERROR; stream.next_in = pSource; - stream.avail_in = (mz_uint32)source_len; + stream.avail_in = (mz_uint32)*pSource_len; stream.next_out = pDest; stream.avail_out = (mz_uint32)*pDest_len; @@ -573,6 +572,7 @@ int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char return status; status = mz_inflate(&stream, MZ_FINISH); + *pSource_len = *pSource_len - stream.avail_in; if (status != MZ_STREAM_END) { mz_inflateEnd(&stream); @@ -583,6 +583,11 @@ int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char return mz_inflateEnd(&stream); } +int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len) +{ + return mz_uncompress2(pDest, pDest_len, pSource, &source_len); +} + const char *mz_error(int err) { static struct diff --git a/sources/3rdparty/miniz/miniz.h b/sources/3rdparty/miniz/miniz.h index 3018daeb..7789be9a 100644 --- a/sources/3rdparty/miniz/miniz.h +++ b/sources/3rdparty/miniz/miniz.h @@ -388,6 +388,7 @@ MINIZ_EXPORT int mz_inflateEnd(mz_streamp pStream); /* Single-call decompression. */ /* Returns MZ_OK on success, or one of the error codes from mz_inflate() on failure. */ MINIZ_EXPORT int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len); +MINIZ_EXPORT int mz_uncompress2(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong *pSource_len); /* Returns a string description of the specified error code, or NULL if the error code is invalid. */ MINIZ_EXPORT const char *mz_error(int err); @@ -453,6 +454,7 @@ typedef void *const voidpc; #define inflate mz_inflate #define inflateEnd mz_inflateEnd #define uncompress mz_uncompress +#define uncompress2 mz_uncompress2 #define crc32 mz_crc32 #define adler32 mz_adler32 #define MAX_WBITS 15