zstdseek_decompress: fix decompression with data left in input buffer

dev
Azat Khuzhin 2018-09-16 18:04:43 +03:00
parent 7ff74c89fa
commit b52867a97f
No known key found for this signature in database
GPG Key ID: B86086848EF8686D
1 changed files with 1 additions and 1 deletions

View File

@ -313,8 +313,8 @@ static size_t ZSTD_seekable_loadSeekTable(ZSTD_seekable* zs)
/* compute cumulative positions */ /* compute cumulative positions */
for (; idx < numFrames; idx++) { for (; idx < numFrames; idx++) {
if (pos + sizePerEntry > SEEKABLE_BUFF_SIZE) { if (pos + sizePerEntry > SEEKABLE_BUFF_SIZE) {
U32 const toRead = MIN(remaining, SEEKABLE_BUFF_SIZE);
U32 const offset = SEEKABLE_BUFF_SIZE - pos; U32 const offset = SEEKABLE_BUFF_SIZE - pos;
U32 const toRead = MIN(remaining, SEEKABLE_BUFF_SIZE - offset);
memmove(zs->inBuff, zs->inBuff + pos, offset); /* move any data we haven't read yet */ memmove(zs->inBuff, zs->inBuff + pos, offset); /* move any data we haven't read yet */
CHECK_IO(src.read(src.opaque, zs->inBuff+offset, toRead)); CHECK_IO(src.read(src.opaque, zs->inBuff+offset, toRead));
remaining -= toRead; remaining -= toRead;