From ee28a0def40ba0dac1ca957e543d8ca73951d0bd Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Mon, 6 Jul 2015 23:45:35 -0800 Subject: [PATCH] Fixed issue #34 and #31 --- lib/zstd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/zstd.c b/lib/zstd.c index 0eb0c2e7..277307fb 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);