From ce8e5b6ed08aafc9b37c30ca90a1eeac130159de Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Fri, 11 Oct 2013 19:11:41 -0500 Subject: [PATCH] lzx-decompress.c: Fix alignment bug The pretree decode table was not declared to be 16 byte aligned, as expected by make_huffman_decode_table(). This bug had no effect if the compiler aligned this table on a 16 byte boundary anyway, but if not it caused a segmentation fault on x86 platforms where the SSE2 instructions were available, since in that case stores requiring 16 byte alignment are used to fill in table entries. --- src/decompress.c | 3 ++- src/lzx-decompress.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/decompress.c b/src/decompress.c index 1ef88236..227bfb06 100644 --- a/src/decompress.c +++ b/src/decompress.c @@ -53,7 +53,8 @@ * @decode_table: The array in which to create the fast huffman decoding * table. It must have a length of at least * (2**table_bits) + 2 * num_syms to guarantee - * that there is enough space. + * that there is enough space. Also must be 16-byte + * aligned (at least when USE_SSE2_FILL gets defined). * * @num_syms: Number of symbols in the alphabet, including symbols * that do not appear in this particular input chunk. diff --git a/src/lzx-decompress.c b/src/lzx-decompress.c index 99502d47..a24b0832 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; -- 2.43.0