mirror of
https://github.com/zlib-ng/minizip-ng
synced 2025-03-28 21:13:18 +00:00
fix io buf seek bug
This commit is contained in:
parent
5507aa75ab
commit
0b262c6b2f
24
ioapi_buf.c
24
ioapi_buf.c
@ -276,11 +276,15 @@ long ZCALLBACK fseek_buf_func (opaque, stream, offset, origin)
|
||||
}
|
||||
if (bufio->readBufferLength > 0)
|
||||
{
|
||||
if ((origin == ZLIB_FILEFUNC_SEEK_CUR) && (offset < bufio->readBufferLength))
|
||||
if (origin == ZLIB_FILEFUNC_SEEK_CUR)
|
||||
{
|
||||
bufio->readBufferLength -= offset;
|
||||
memcpy(bufio->readBuffer, bufio->readBuffer + offset, bufio->readBufferLength);
|
||||
return 0;
|
||||
if (offset <= bufio->readBufferLength)
|
||||
{
|
||||
bufio->readBufferLength -= offset;
|
||||
memcpy(bufio->readBuffer, bufio->readBuffer + offset, bufio->readBufferLength);
|
||||
return 0;
|
||||
}
|
||||
offset -= bufio->readBufferLength;
|
||||
}
|
||||
bufio->readBufferLength = 0;
|
||||
}
|
||||
@ -310,11 +314,15 @@ long ZCALLBACK fseek64_buf_func (opaque, stream, offset, origin)
|
||||
}
|
||||
if (bufio->readBufferLength > 0)
|
||||
{
|
||||
if ((origin == ZLIB_FILEFUNC_SEEK_CUR) && (offset < bufio->readBufferLength))
|
||||
if (origin == ZLIB_FILEFUNC_SEEK_CUR)
|
||||
{
|
||||
bufio->readBufferLength -= (uLong)offset;
|
||||
memcpy(bufio->readBuffer, bufio->readBuffer + (uLong)offset, bufio->readBufferLength);
|
||||
return 0;
|
||||
if (offset <= bufio->readBufferLength)
|
||||
{
|
||||
bufio->readBufferLength -= (uLong)offset;
|
||||
memcpy(bufio->readBuffer, bufio->readBuffer + (uLong)offset, bufio->readBufferLength);
|
||||
return 0;
|
||||
}
|
||||
offset -= bufio->readBufferLength;
|
||||
}
|
||||
bufio->readBufferLength = 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user