mirror of
https://github.com/zlib-ng/minizip-ng
synced 2026-08-25 14:26:08 -04:00
Changed mz_stream_mem_read to use size_t; changed boundareis check to be suitable for size_t
This commit is contained in:
parent
051bf8c38e
commit
1bc5c69413
1 changed files with 8 additions and 4 deletions
|
|
@ -103,17 +103,21 @@ int32_t mz_stream_mem_is_open(void *stream) {
|
|||
return MZ_OK;
|
||||
}
|
||||
|
||||
int32_t mz_stream_mem_read(void *stream, void *buf, int32_t size) {
|
||||
int32_t mz_stream_mem_read(void *stream, void *buf, size_t size) {
|
||||
mz_stream_mem *mem = (mz_stream_mem *)stream;
|
||||
|
||||
if (size == 0)
|
||||
return 0;
|
||||
|
||||
if (mem->size < mem->position)
|
||||
return 0;
|
||||
|
||||
if (size > mem->size - mem->position)
|
||||
size = mem->size - mem->position;
|
||||
|
||||
if (mem->position + size > mem->limit)
|
||||
size = mem->limit - mem->position;
|
||||
|
||||
if (size <= 0)
|
||||
return 0;
|
||||
|
||||
memcpy(buf, mem->buffer + mem->position, size);
|
||||
mem->position += size;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue