X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Flzx-decompress.c;h=96332dd8f40cf6066ed43d19c482d38c7c6e5408;hb=8f071f84246b394d261ce028b87fbedf4c579c6e;hp=99502d47edf451a2a3c295593d484bbe61bb98c7;hpb=61db93f82eca3fe9f7676355c709c58cc425a6ad;p=wimlib diff --git a/src/lzx-decompress.c b/src/lzx-decompress.c index 99502d47..96332dd8 100644 --- a/src/lzx-decompress.c +++ b/src/lzx-decompress.c @@ -204,7 +204,8 @@ lzx_read_code_lens(struct input_bitstream *istream, u8 lens[], { /* Declare the decoding table and length table for the pretree. */ u16 pretree_decode_table[(1 << LZX_PRETREE_TABLEBITS) + - (LZX_PRETREE_NUM_SYMBOLS * 2)]; + (LZX_PRETREE_NUM_SYMBOLS * 2)] + _aligned_attribute(DECODE_TABLE_ALIGNMENT); u8 pretree_lens[LZX_PRETREE_NUM_SYMBOLS]; unsigned i; unsigned len; @@ -655,8 +656,6 @@ lzx_decode_match(unsigned main_element, int block_type, /* Verify that the match is in the bounds of the part of the window * currently in use, then copy the source of the match to the current * position. */ - match_dest = window + window_pos; - match_src = match_dest - match_offset; if (match_len > bytes_remaining) { DEBUG("lzx_decode_match(): Match of length %u bytes overflows " @@ -664,13 +663,16 @@ lzx_decode_match(unsigned main_element, int block_type, return -1; } - if (match_src < window) { + if (match_offset > window_pos) { DEBUG("lzx_decode_match(): Match of length %u bytes references " "data before window (match_offset = %u, window_pos = %u)", match_len, match_offset, window_pos); return -1; } + match_dest = window + window_pos; + match_src = match_dest - match_offset; + #if 0 printf("Match: src %u, dst %u, len %u\n", match_src - window, match_dest - window,