]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Fix ZSTD_sizeof_matchState() Calculation
authorW. Felix Handte <w@felixhandte.com>
Mon, 16 Sep 2019 21:45:40 +0000 (17:45 -0400)
committerW. Felix Handte <w@felixhandte.com>
Thu, 10 Oct 2019 17:40:16 +0000 (13:40 -0400)
lib/compress/zstd_compress.c

index 431307f03cadfcb441f7b5231b419ea0e282ae05..becdc728fdc7e8e4485edddc6b45faed2111af39 100644 (file)
@@ -1076,7 +1076,7 @@ ZSTD_sizeof_matchState(const ZSTD_compressionParameters* const cParams,
     size_t const chainSize = (cParams->strategy == ZSTD_fast) ? 0 : ((size_t)1 << cParams->chainLog);
     size_t const hSize = ((size_t)1) << cParams->hashLog;
     U32    const hashLog3 = (forCCtx && cParams->minMatch==3) ? MIN(ZSTD_HASHLOG3_MAX, cParams->windowLog) : 0;
-    size_t const h3Size = ((size_t)1) << hashLog3;
+    size_t const h3Size = hashLog3 ? ((size_t)1) << hashLog3 : 0;
     size_t const tableSpace = ZSTD_cwksp_alloc_size(chainSize * sizeof(U32))
                             + ZSTD_cwksp_alloc_size(hSize * sizeof(U32))
                             + ZSTD_cwksp_alloc_size(h3Size * sizeof(U32));