From: Yann Collet Date: Mon, 23 Mar 2015 22:15:22 +0000 (+0100) Subject: Fixed issue #28 X-Git-Tag: v0.1.0~3^2~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bbfa7d77c9a802b983b456e1695f7cc82ba2fa37;p=thirdparty%2Fzstd.git Fixed issue #28 --- diff --git a/lib/fse.c b/lib/fse.c index e07b951cd..2861fd9f1 100644 --- a/lib/fse.c +++ b/lib/fse.c @@ -542,7 +542,7 @@ unsigned FSE_optimalTableLog(unsigned maxTableLog, size_t srcSize, unsigned maxS U32 tableLog = maxTableLog; if (tableLog==0) tableLog = FSE_DEFAULT_TABLELOG; if ((FSE_highbit32((U32)(srcSize - 1)) - 2) < tableLog) tableLog = FSE_highbit32((U32)(srcSize - 1)) - 2; /* Accuracy can be reduced */ - if ((FSE_highbit32(maxSymbolValue+1)+1) > tableLog) tableLog = FSE_highbit32(maxSymbolValue+1)+1; /* Need a minimum to safely represent all symbol values */ + if ((FSE_highbit32(maxSymbolValue)+2) > tableLog) tableLog = FSE_highbit32(maxSymbolValue)+2; /* Need a minimum to safely represent all symbol values */ if (tableLog < FSE_MIN_TABLELOG) tableLog = FSE_MIN_TABLELOG; if (tableLog > FSE_MAX_TABLELOG) tableLog = FSE_MAX_TABLELOG; return tableLog;