]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Fixed issue #34 and #31
authorYann Collet <yann.collet.73@gmail.com>
Tue, 7 Jul 2015 07:45:35 +0000 (23:45 -0800)
committerYann Collet <yann.collet.73@gmail.com>
Tue, 7 Jul 2015 07:45:35 +0000 (23:45 -0800)
lib/zstd.c

index 0eb0c2e785ea4aa531fa0ec330958cf9dc13ea29..277307fbcce10a38e0133cc46dcf8080cf47f90b 100644 (file)
@@ -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);