Skip to content

Commit 60c3198

Browse files
zmodemmadler
authored andcommitted
Fix the copy of pending_buf in deflateCopy() for the LIT_MEM case.
1 parent ee474ff commit 60c3198

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

deflate.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -493,11 +493,7 @@ int ZEXPORT deflateInit2_(z_streamp strm, int level, int method,
493493
* symbols from which it is being constructed.
494494
*/
495495

496-
#ifdef LIT_MEM
497-
s->pending_buf = (uchf *) ZALLOC(strm, s->lit_bufsize, 5);
498-
#else
499-
s->pending_buf = (uchf *) ZALLOC(strm, s->lit_bufsize, 4);
500-
#endif
496+
s->pending_buf = (uchf *) ZALLOC(strm, s->lit_bufsize, LIT_BUFS);
501497
s->pending_buf_size = (ulg)s->lit_bufsize * 4;
502498

503499
if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL ||
@@ -1310,7 +1306,7 @@ int ZEXPORT deflateCopy(z_streamp dest, z_streamp source) {
13101306
ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte));
13111307
ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos));
13121308
ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos));
1313-
ds->pending_buf = (uchf *) ZALLOC(dest, ds->lit_bufsize, 4);
1309+
ds->pending_buf = (uchf *) ZALLOC(dest, ds->lit_bufsize, LIT_BUFS);
13141310

13151311
if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL ||
13161312
ds->pending_buf == Z_NULL) {
@@ -1321,7 +1317,7 @@ int ZEXPORT deflateCopy(z_streamp dest, z_streamp source) {
13211317
zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte));
13221318
zmemcpy((voidpf)ds->prev, (voidpf)ss->prev, ds->w_size * sizeof(Pos));
13231319
zmemcpy((voidpf)ds->head, (voidpf)ss->head, ds->hash_size * sizeof(Pos));
1324-
zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size);
1320+
zmemcpy(ds->pending_buf, ss->pending_buf, ds->lit_bufsize * LIT_BUFS);
13251321

13261322
ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf);
13271323
#ifdef LIT_MEM

deflate.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,11 @@ typedef struct internal_state {
222222
*/
223223

224224
#ifdef LIT_MEM
225+
# define LIT_BUFS 5
225226
ushf *d_buf; /* buffer for distances */
226227
uchf *l_buf; /* buffer for literals/lengths */
227228
#else
229+
# define LIT_BUFS 4
228230
uchf *sym_buf; /* buffer for distances and literals/lengths */
229231
#endif
230232

0 commit comments

Comments
 (0)