From: Nick Terrell Date: Fri, 13 Oct 2017 19:47:00 +0000 (-0700) Subject: Fix invalid use of dictionary offcode table X-Git-Tag: v1.3.3^2~56^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=24ac2dbd2a56dccbfe52293ac98c3cdd8eb0c0c0;p=thirdparty%2Fzstd.git Fix invalid use of dictionary offcode table Fixes #888. --- diff --git a/lib/compress/zstd_compress.c b/lib/compress/zstd_compress.c index e072fe30e..3f1a7cdba 100644 --- a/lib/compress/zstd_compress.c +++ b/lib/compress/zstd_compress.c @@ -1536,6 +1536,12 @@ MEM_STATIC size_t ZSTD_compressSequences(seqStore_t* seqStorePtr, int const uncompressibleError = (cSize == ERROR(dstSize_tooSmall)) && (srcSize <= dstCapacity); if (ZSTD_isError(cSize) && !uncompressibleError) return cSize; + /* We check that dictionaries have offset codes available for the first + * block. After the first block, the offcode table might not have large + * enough codes to represent the offsets in the data. + */ + if (entropy->offcode_repeatMode == FSE_repeat_valid) + entropy->offcode_repeatMode = FSE_repeat_check; /* Check compressibility */ { size_t const minGain = ZSTD_minGain(srcSize); /* note : fixed formula, maybe should depend on compression level, or strategy */