From 48ca09d52c51b3554a4b7918504a346b842bef4c Mon Sep 17 00:00:00 2001 From: Hans Wennborg Date: Fri, 15 Dec 2023 15:10:19 +0100 Subject: [PATCH] Fix "pendingBuf overflow" assert in LIT_MEM mode Since each element in s->d_buf is 2 bytes, the sx index should be multiplied by 2 in the assert. Fixes #897 --- trees.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/trees.c b/trees.c index 5ca23e938..38135273c 100644 --- a/trees.c +++ b/trees.c @@ -938,7 +938,8 @@ local void compress_block(deflate_state *s, const ct_data *ltree, /* Check for no overlay of pending_buf on needed symbols */ #ifdef LIT_MEM - Assert(s->pending < (s->lit_bufsize << 1) + sx, "pendingBuf overflow"); + Assert(s->pending < (s->lit_bufsize << 1) + (sx << 1), + "pendingBuf overflow"); #else Assert(s->pending < s->lit_bufsize + sx, "pendingBuf overflow"); #endif