Fixed casting and 16-bit zlib limitation.

This commit is contained in:
Nathan Moinvaziri 2018-01-22 08:51:07 -08:00
parent 397d2d5ab3
commit 930f9188a5
4 changed files with 9 additions and 9 deletions

View File

@ -125,7 +125,7 @@ int32_t mz_stream_bzip_read(void *stream, void *buf, int32_t size)
return 0;
bzip->bzstream.next_out = (char *)buf;
bzip->bzstream.avail_out = (uint16_t)size;
bzip->bzstream.avail_out = (unsigned int)size;
do
{
@ -254,7 +254,7 @@ int32_t mz_stream_bzip_write(void *stream, const void *buf, int32_t size)
bzip->bzstream.next_in = (char *)buf;
bzip->bzstream.avail_in = size;
bzip->bzstream.avail_in = (unsigned int)size;
mz_stream_bzip_compress(stream, BZ_RUN);

View File

@ -147,7 +147,7 @@ int32_t mz_stream_lzma_read(void *stream, void *buf, int32_t size)
lzma->lstream.next_out = (uint8_t*)buf;
lzma->lstream.avail_out = (uint16_t)size;
lzma->lstream.avail_out = (size_t)size;
do
{
@ -266,7 +266,7 @@ int32_t mz_stream_lzma_write(void *stream, const void *buf, int32_t size)
lzma->lstream.next_in = (uint8_t*)buf;
lzma->lstream.avail_in = size;
lzma->lstream.avail_in = (size_t)size;
mz_stream_lzma_code(stream, LZMA_RUN);

View File

@ -128,8 +128,8 @@ int32_t mz_stream_zlib_read(void *stream, void *buf, int32_t size)
int32_t err = Z_OK;
zlib->zstream.next_out = (uint8_t*)buf;
zlib->zstream.avail_out = (uint32_t)size;
zlib->zstream.next_out = (Bytef*)buf;
zlib->zstream.avail_out = (uInt)size;
do
{
@ -255,8 +255,8 @@ int32_t mz_stream_zlib_write(void *stream, const void *buf, int32_t size)
mz_stream_zlib *zlib = (mz_stream_zlib *)stream;
zlib->zstream.next_in = (uint8_t*)buf;
zlib->zstream.avail_in = size;
zlib->zstream.next_in = (Bytef*)buf;
zlib->zstream.avail_in = (uInt)size;
mz_stream_zlib_deflate(stream, Z_NO_FLUSH);

View File

@ -1314,7 +1314,7 @@ extern int32_t mz_zip_entry_read(void *handle, void *buf, uint32_t len)
if (zip == NULL || zip->entry_opened == 0)
return MZ_PARAM_ERROR;
if (sizeof(unsigned int) == 2 && len > UINT16_MAX) // Zlib limitation
if (UINT_MAX == UINT16_MAX && len > UINT16_MAX) // Zlib limitation
return MZ_PARAM_ERROR;
if (len == 0 || zip->file_info.uncompressed_size == 0)
return 0;