From: Yann Collet Date: Tue, 7 Jul 2015 07:45:35 +0000 (-0800) Subject: Fixed issue #34 and #31 X-Git-Tag: v0.1.0~3^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ee28a0def40ba0dac1ca957e543d8ca73951d0bd;p=thirdparty%2Fzstd.git Fixed issue #34 and #31 --- diff --git a/lib/zstd.c b/lib/zstd.c index 0eb0c2e78..277307fbc 100644 --- a/lib/zstd.c +++ b/lib/zstd.c @@ -737,7 +737,7 @@ static size_t ZSTD_compressSequences(BYTE* dst, size_t maxDstSize, /* Encoding table of Literal Lengths */ max = MaxLL; mostFrequent = FSE_countFast(count, &max, seqStorePtr->litLengthStart, nbSeq); - if (mostFrequent == nbSeq) + if ((mostFrequent == nbSeq) && (nbSeq > 2)) { *op++ = *(seqStorePtr->litLengthStart); FSE_buildCTable_rle(CTable_LitLength, (BYTE)max); @@ -771,7 +771,7 @@ static size_t ZSTD_compressSequences(BYTE* dst, size_t maxDstSize, offsetBitsPtr += nbSeq; mostFrequent = FSE_countFast(count, &max, offsetBits_start, nbSeq); } - if (mostFrequent == nbSeq) + if ((mostFrequent == nbSeq) && (nbSeq > 2)) { *op++ = *offsetBits_start; FSE_buildCTable_rle(CTable_OffsetBits, (BYTE)max); @@ -794,7 +794,7 @@ static size_t ZSTD_compressSequences(BYTE* dst, size_t maxDstSize, /* Encoding Table of MatchLengths */ max = MaxML; mostFrequent = FSE_countFast(count, &max, seqStorePtr->matchLengthStart, nbSeq); - if (mostFrequent == nbSeq) + if ((mostFrequent == nbSeq) && (nbSeq > 2)) { *op++ = *seqStorePtr->matchLengthStart; FSE_buildCTable_rle(CTable_MatchLength, (BYTE)max);