]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Fix DDSS Load 2729/head
authorW. Felix Handte <w@felixhandte.com>
Thu, 22 Jul 2021 16:37:35 +0000 (12:37 -0400)
committerW. Felix Handte <w@felixhandte.com>
Tue, 27 Jul 2021 15:49:44 +0000 (11:49 -0400)
This PR fixes an incorrect comparison in figuring out `minChain` in
`ZSTD_dedicatedDictSearch_lazy_loadDictionary()`. This incorrect comparison
had been masked by the fact that `idx` was always 1, until @terrelln changed
that in #2726.

Credit-to: OSS-Fuzz
lib/compress/zstd_lazy.c

index 4dfd9d9ed3f0b4cdef91234fdba7e3ccf9f30ca5..e1f5a4f0dd7466bb7665cfcf6a4b29753d15918f 100644 (file)
@@ -450,7 +450,7 @@ void ZSTD_dedicatedDictSearch_lazy_loadDictionary(ZSTD_matchState_t* ms, const B
     U32* const chainTable = ms->chainTable;
     U32 const chainSize = 1 << ms->cParams.chainLog;
     U32 idx = ms->nextToUpdate;
-    U32 const minChain = chainSize < target ? target - chainSize : idx;
+    U32 const minChain = chainSize < target - idx ? target - chainSize : idx;
     U32 const bucketSize = 1 << ZSTD_LAZY_DDSS_BUCKET_LOG;
     U32 const cacheSize = bucketSize - 1;
     U32 const chainAttempts = (1 << ms->cParams.searchLog) - cacheSize;