aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--archival/libarchive/decompress_unlzma.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/archival/libarchive/decompress_unlzma.c b/archival/libarchive/decompress_unlzma.c
index ca32bd82c..a89b846a0 100644
--- a/archival/libarchive/decompress_unlzma.c
+++ b/archival/libarchive/decompress_unlzma.c
@@ -214,8 +214,6 @@ unpack_lzma_stream(transformer_aux_data_t *aux UNUSED_PARAM, int src_fd, int dst
214 uint32_t pos_state_mask; 214 uint32_t pos_state_mask;
215 uint32_t literal_pos_mask; 215 uint32_t literal_pos_mask;
216 uint16_t *p; 216 uint16_t *p;
217 int num_bits;
218 int num_probs;
219 rc_t *rc; 217 rc_t *rc;
220 int i; 218 int i;
221 uint8_t *buffer; 219 uint8_t *buffer;
@@ -247,11 +245,15 @@ unpack_lzma_stream(transformer_aux_data_t *aux UNUSED_PARAM, int src_fd, int dst
247 245
248 buffer = xmalloc(MIN(header.dst_size, header.dict_size)); 246 buffer = xmalloc(MIN(header.dst_size, header.dict_size));
249 247
250 num_probs = LZMA_BASE_SIZE + (LZMA_LIT_SIZE << (lc + lp)); 248 {
251 p = xmalloc(num_probs * sizeof(*p)); 249 int num_probs;
252 num_probs += LZMA_LITERAL - LZMA_BASE_SIZE; 250
253 for (i = 0; i < num_probs; i++) 251 num_probs = LZMA_BASE_SIZE + (LZMA_LIT_SIZE << (lc + lp));
254 p[i] = (1 << RC_MODEL_TOTAL_BITS) >> 1; 252 p = xmalloc(num_probs * sizeof(*p));
253 num_probs += LZMA_LITERAL - LZMA_BASE_SIZE;
254 for (i = 0; i < num_probs; i++)
255 p[i] = (1 << RC_MODEL_TOTAL_BITS) >> 1;
256 }
255 257
256 rc = rc_init(src_fd); /*, RC_BUFFER_SIZE); */ 258 rc = rc_init(src_fd); /*, RC_BUFFER_SIZE); */
257 259
@@ -310,6 +312,7 @@ unpack_lzma_stream(transformer_aux_data_t *aux UNUSED_PARAM, int src_fd, int dst
310 goto one_byte2; 312 goto one_byte2;
311#endif 313#endif
312 } else { 314 } else {
315 int num_bits;
313 int offset; 316 int offset;
314 uint16_t *prob2; 317 uint16_t *prob2;
315#define prob_len prob2 318#define prob_len prob2