From: Yann Collet Date: Wed, 3 Aug 2016 01:36:03 +0000 (+0200) Subject: fixed dictionary generation, reported by Bartosz Taudul X-Git-Tag: v0.8.1^2~38 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e0b4a2d40f6a6e099e665fc241cd4cbb16a0920b;p=thirdparty%2Fzstd.git fixed dictionary generation, reported by Bartosz Taudul --- diff --git a/lib/dictBuilder/zdict.c b/lib/dictBuilder/zdict.c index e30168cbd..a18ab4469 100644 --- a/lib/dictBuilder/zdict.c +++ b/lib/dictBuilder/zdict.c @@ -332,12 +332,13 @@ static dictItem ZDICT_analyzePos( } while (length >=MINMATCHLENGTH); /* look backward */ - do { - length = ZDICT_count(b + pos, b + suffix[start-1]); - if (length >= LLIMIT) length = LLIMIT-1; - lengthList[length]++; - if (length >=MINMATCHLENGTH) start--; - } while(length >= MINMATCHLENGTH); + length = MINMATCHLENGTH; + while ((length >= MINMATCHLENGTH) & (start > 0)) { + length = ZDICT_count(b + pos, b + suffix[start - 1]); + if (length >= LLIMIT) length = LLIMIT - 1; + lengthList[length]++; + if (length >= MINMATCHLENGTH) start--; + } /* largest useful length */ memset(cumulLength, 0, sizeof(cumulLength));