diff options
Diffstat (limited to 'infblock.c')
-rw-r--r-- | infblock.c | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* infblock.c -- interpret and process block types to last block | 1 | /* infblock.c -- interpret and process block types to last block |
2 | * Copyright (C) 1995-1996 Mark Adler | 2 | * Copyright (C) 1995-1998 Mark Adler |
3 | * For conditions of distribution and use, see copyright notice in zlib.h | 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
4 | */ | 4 | */ |
5 | 5 | ||
@@ -12,7 +12,7 @@ | |||
12 | struct inflate_codes_state {int dummy;}; /* for buggy compilers */ | 12 | struct inflate_codes_state {int dummy;}; /* for buggy compilers */ |
13 | 13 | ||
14 | /* Table for deflate from PKZIP's appnote.txt. */ | 14 | /* Table for deflate from PKZIP's appnote.txt. */ |
15 | local uInt border[] = { /* Order of the bit length code lengths */ | 15 | local const uInt border[] = { /* Order of the bit length code lengths */ |
16 | 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; | 16 | 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; |
17 | 17 | ||
18 | /* | 18 | /* |
@@ -224,8 +224,6 @@ int r; | |||
224 | } | 224 | } |
225 | #endif | 225 | #endif |
226 | t = 258 + (t & 0x1f) + ((t >> 5) & 0x1f); | 226 | t = 258 + (t & 0x1f) + ((t >> 5) & 0x1f); |
227 | if (t < 19) | ||
228 | t = 19; | ||
229 | if ((s->sub.trees.blens = (uIntf*)ZALLOC(z, t, sizeof(uInt))) == Z_NULL) | 227 | if ((s->sub.trees.blens = (uIntf*)ZALLOC(z, t, sizeof(uInt))) == Z_NULL) |
230 | { | 228 | { |
231 | r = Z_MEM_ERROR; | 229 | r = Z_MEM_ERROR; |
@@ -249,6 +247,7 @@ int r; | |||
249 | &s->sub.trees.tb, z); | 247 | &s->sub.trees.tb, z); |
250 | if (t != Z_OK) | 248 | if (t != Z_OK) |
251 | { | 249 | { |
250 | ZFREE(z, s->sub.trees.blens); | ||
252 | r = t; | 251 | r = t; |
253 | if (r == Z_DATA_ERROR) | 252 | if (r == Z_DATA_ERROR) |
254 | s->mode = BAD; | 253 | s->mode = BAD; |
@@ -287,6 +286,8 @@ int r; | |||
287 | if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) || | 286 | if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) || |
288 | (c == 16 && i < 1)) | 287 | (c == 16 && i < 1)) |
289 | { | 288 | { |
289 | inflate_trees_free(s->sub.trees.tb, z); | ||
290 | ZFREE(z, s->sub.trees.blens); | ||
290 | s->mode = BAD; | 291 | s->mode = BAD; |
291 | z->msg = (char*)"invalid bit length repeat"; | 292 | z->msg = (char*)"invalid bit length repeat"; |
292 | r = Z_DATA_ERROR; | 293 | r = Z_DATA_ERROR; |
@@ -314,6 +315,7 @@ int r; | |||
314 | #endif | 315 | #endif |
315 | t = inflate_trees_dynamic(257 + (t & 0x1f), 1 + ((t >> 5) & 0x1f), | 316 | t = inflate_trees_dynamic(257 + (t & 0x1f), 1 + ((t >> 5) & 0x1f), |
316 | s->sub.trees.blens, &bl, &bd, &tl, &td, z); | 317 | s->sub.trees.blens, &bl, &bd, &tl, &td, z); |
318 | ZFREE(z, s->sub.trees.blens); | ||
317 | if (t != Z_OK) | 319 | if (t != Z_OK) |
318 | { | 320 | { |
319 | if (t == (uInt)Z_DATA_ERROR) | 321 | if (t == (uInt)Z_DATA_ERROR) |
@@ -330,7 +332,6 @@ int r; | |||
330 | r = Z_MEM_ERROR; | 332 | r = Z_MEM_ERROR; |
331 | LEAVE | 333 | LEAVE |
332 | } | 334 | } |
333 | ZFREE(z, s->sub.trees.blens); | ||
334 | s->sub.decode.codes = c; | 335 | s->sub.decode.codes = c; |
335 | s->sub.decode.tl = tl; | 336 | s->sub.decode.tl = tl; |
336 | s->sub.decode.td = td; | 337 | s->sub.decode.td = td; |