]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
fixed dictionary generation, reported by Bartosz Taudul
authorYann Collet <yann.collet.73@gmail.com>
Wed, 3 Aug 2016 01:36:03 +0000 (03:36 +0200)
committerYann Collet <yann.collet.73@gmail.com>
Wed, 3 Aug 2016 01:36:03 +0000 (03:36 +0200)
lib/dictBuilder/zdict.c

index e30168cbd7c79f5f362099660070d12c56237716..a18ab4469b96d57ad5d45d7e140a21595269dfa7 100644 (file)
@@ -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));