Skip to content

Commit

Permalink
Fix pending buffer overflow assert with LIT_MEM allocation.
Browse files Browse the repository at this point in the history
Since each element in s->d_buf is 2 bytes, the sx index should be
multiplied by 2 in the assert.

Fixes #897
  • Loading branch information
zmodem authored and madler committed Jan 14, 2024
1 parent 4bd9a71 commit ee474ff
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion trees.c
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,7 @@ 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 < 2 * (s->lit_bufsize + sx), "pendingBuf overflow");
#else
Assert(s->pending < s->lit_bufsize + sx, "pendingBuf overflow");
#endif
Expand Down

0 comments on commit ee474ff

Please sign in to comment.