X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;ds=sidebyside;f=src%2Flzx-decompress.c;h=1cc5113c4515b0f1fa60065f35a1b714982f13e6;hb=8c26ca707e56d9848e52076ad3f7c26ea7fa338d;hp=06e3e0205d264e5fb20172330a96abed90100736;hpb=1ab60207e56968e480be6400c67844017598b7dd;p=wimlib diff --git a/src/lzx-decompress.c b/src/lzx-decompress.c index 06e3e020..1cc5113c 100644 --- a/src/lzx-decompress.c +++ b/src/lzx-decompress.c @@ -7,7 +7,7 @@ */ /* - * Copyright (C) 2012 Eric Biggers + * Copyright (C) 2012, 2013 Eric Biggers * * This file is part of wimlib, a library for working with WIM files. * @@ -318,7 +318,6 @@ static int lzx_read_block_header(struct input_bitstream *istream, unsigned s; unsigned i; unsigned len; - u32 R[3]; ret = bitstream_ensure_bits(istream, 4); if (ret != 0) { @@ -747,32 +746,32 @@ static int lzx_decompress_block(int block_type, unsigned block_size, { unsigned main_element; unsigned end; + int ret; int match_len; - int ret = 0; end = window_pos + block_size; while (window_pos < end) { ret = read_huffsym_using_maintree(istream, tables, &main_element); if (ret != 0) - break; + return ret; if (main_element < LZX_NUM_CHARS) { /* literal: 0 to LZX_NUM_CHARS - 1 */ window[window_pos++] = main_element; } else { /* match: LZX_NUM_CHARS to LZX_MAINTREE_NUM_SYMBOLS - 1 */ - ret = lzx_decode_match(main_element, - block_type, - end - window_pos, - window, - window_pos, - tables, - queue, - istream); - if (ret < 0) - break; - window_pos += ret; + match_len = lzx_decode_match(main_element, + block_type, + end - window_pos, + window, + window_pos, + tables, + queue, + istream); + if (match_len < 0) + return match_len; + window_pos += match_len; } } return 0; @@ -873,7 +872,7 @@ int lzx_decompress(const void *compressed_data, unsigned compressed_len, LZX_DEBUG("LZX_BLOCKTYPE_UNCOMPRESSED"); if (istream.data_bytes_left < block_size) { ERROR("Unexpected end of input when " - "reading %zu bytes from LZX bitstream " + "reading %u bytes from LZX bitstream " "(only have %u bytes left)", block_size, istream.data_bytes_left); return -1;