]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
[fse] Fix FSE_optimalTableLog() for srcSize==1 850/head
authorNick Terrell <terrelln@fb.com>
Sat, 16 Sep 2017 02:00:39 +0000 (19:00 -0700)
committerNick Terrell <terrelln@fb.com>
Mon, 18 Sep 2017 21:11:18 +0000 (14:11 -0700)
lib/compress/fse_compress.c

index cc9fa73514ade7af57bf247526a65ee562650266..599280b90ca37dfdf688dab243e1be9f99f5dc66 100644 (file)
@@ -461,6 +461,7 @@ static unsigned FSE_minTableLog(size_t srcSize, unsigned maxSymbolValue)
     U32 minBitsSrc = BIT_highbit32((U32)(srcSize - 1)) + 1;
     U32 minBitsSymbols = BIT_highbit32(maxSymbolValue) + 2;
     U32 minBits = minBitsSrc < minBitsSymbols ? minBitsSrc : minBitsSymbols;
+    assert(srcSize > 1); /* Not supported, RLE should be used instead */
     return minBits;
 }
 
@@ -469,6 +470,7 @@ unsigned FSE_optimalTableLog_internal(unsigned maxTableLog, size_t srcSize, unsi
     U32 maxBitsSrc = BIT_highbit32((U32)(srcSize - 1)) - minus;
     U32 tableLog = maxTableLog;
     U32 minBits = FSE_minTableLog(srcSize, maxSymbolValue);
+    assert(srcSize > 1); /* Not supported, RLE should be used instead */
     if (tableLog==0) tableLog = FSE_DEFAULT_TABLELOG;
     if (maxBitsSrc < tableLog) tableLog = maxBitsSrc;   /* Accuracy can be reduced */
     if (minBits > tableLog) tableLog = minBits;   /* Need a minimum to safely represent all symbol values */