From: Azat Khuzhin Date: Sun, 16 Sep 2018 15:04:43 +0000 (+0300) Subject: zstdseek_decompress: fix decompression with data left in input buffer X-Git-Tag: v0.0.29~9^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b52867a97f712ec2d7a666bbb592f4fa6c8e6907;p=thirdparty%2Fzstd.git zstdseek_decompress: fix decompression with data left in input buffer --- diff --git a/contrib/seekable_format/zstdseek_decompress.c b/contrib/seekable_format/zstdseek_decompress.c index 2b109b9d0..b4c48754e 100644 --- a/contrib/seekable_format/zstdseek_decompress.c +++ b/contrib/seekable_format/zstdseek_decompress.c @@ -313,8 +313,8 @@ static size_t ZSTD_seekable_loadSeekTable(ZSTD_seekable* zs) /* compute cumulative positions */ for (; idx < numFrames; idx++) { if (pos + sizePerEntry > SEEKABLE_BUFF_SIZE) { - U32 const toRead = MIN(remaining, SEEKABLE_BUFF_SIZE); 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 */ CHECK_IO(src.read(src.opaque, zs->inBuff+offset, toRead)); remaining -= toRead;