diff options
author | Hans Wennborg <hans@chromium.org> | 2023-12-20 12:26:25 +0100 |
---|---|---|
committer | Mark Adler <madler@alumni.caltech.edu> | 2024-01-13 22:30:30 -0800 |
commit | 60c31985ecdc2b40873564867e1ad2aef0b88697 (patch) | |
tree | 9057a2b8e3d17e9387b6e4d1dda8823dfcf84ecc | |
parent | ee474ff2d11715485a87b123edbdd615ba218b88 (diff) | |
download | zlib-60c31985ecdc2b40873564867e1ad2aef0b88697.tar.gz zlib-60c31985ecdc2b40873564867e1ad2aef0b88697.tar.bz2 zlib-60c31985ecdc2b40873564867e1ad2aef0b88697.zip |
Fix the copy of pending_buf in deflateCopy() for the LIT_MEM case.
-rw-r--r-- | deflate.c | 10 | ||||
-rw-r--r-- | deflate.h | 2 |
2 files changed, 5 insertions, 7 deletions
@@ -493,11 +493,7 @@ int ZEXPORT deflateInit2_(z_streamp strm, int level, int method, | |||
493 | * symbols from which it is being constructed. | 493 | * symbols from which it is being constructed. |
494 | */ | 494 | */ |
495 | 495 | ||
496 | #ifdef LIT_MEM | 496 | s->pending_buf = (uchf *) ZALLOC(strm, s->lit_bufsize, LIT_BUFS); |
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 | ||
501 | s->pending_buf_size = (ulg)s->lit_bufsize * 4; | 497 | s->pending_buf_size = (ulg)s->lit_bufsize * 4; |
502 | 498 | ||
503 | if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL || | 499 | 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) { | |||
1310 | ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte)); | 1306 | ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte)); |
1311 | ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos)); | 1307 | ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos)); |
1312 | ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos)); | 1308 | 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); |
1314 | 1310 | ||
1315 | if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL || | 1311 | if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL || |
1316 | ds->pending_buf == Z_NULL) { | 1312 | ds->pending_buf == Z_NULL) { |
@@ -1321,7 +1317,7 @@ int ZEXPORT deflateCopy(z_streamp dest, z_streamp source) { | |||
1321 | zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte)); | 1317 | zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte)); |
1322 | zmemcpy((voidpf)ds->prev, (voidpf)ss->prev, ds->w_size * sizeof(Pos)); | 1318 | zmemcpy((voidpf)ds->prev, (voidpf)ss->prev, ds->w_size * sizeof(Pos)); |
1323 | zmemcpy((voidpf)ds->head, (voidpf)ss->head, ds->hash_size * sizeof(Pos)); | 1319 | 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); |
1325 | 1321 | ||
1326 | ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf); | 1322 | ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf); |
1327 | #ifdef LIT_MEM | 1323 | #ifdef LIT_MEM |
@@ -222,9 +222,11 @@ typedef struct internal_state { | |||
222 | */ | 222 | */ |
223 | 223 | ||
224 | #ifdef LIT_MEM | 224 | #ifdef LIT_MEM |
225 | # define LIT_BUFS 5 | ||
225 | ushf *d_buf; /* buffer for distances */ | 226 | ushf *d_buf; /* buffer for distances */ |
226 | uchf *l_buf; /* buffer for literals/lengths */ | 227 | uchf *l_buf; /* buffer for literals/lengths */ |
227 | #else | 228 | #else |
229 | # define LIT_BUFS 4 | ||
228 | uchf *sym_buf; /* buffer for distances and literals/lengths */ | 230 | uchf *sym_buf; /* buffer for distances and literals/lengths */ |
229 | #endif | 231 | #endif |
230 | 232 | ||