X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2F4xm.c;h=336c651d3172963f6f574cc10b163fda35f258ee;hb=7b9f0b80593d9b33e08106947bd432303848ce12;hp=2b88c899d0a5d0f55eb0ca87874a2946df0360ec;hpb=3e076faf3b86bb16f746e7c9b0cf3dac5f9a851a;p=ffmpeg diff --git a/libavcodec/4xm.c b/libavcodec/4xm.c index 2b88c899d0a..336c651d317 100644 --- a/libavcodec/4xm.c +++ b/libavcodec/4xm.c @@ -158,7 +158,7 @@ typedef struct FourXContext { #define FIX_1_847759065 121095 #define FIX_2_613125930 171254 -#define MULTIPLY(var, const) (((var) * (const)) >> 16) +#define MULTIPLY(var, const) ((int)((var) * (unsigned)(const)) >> 16) static void idct(int16_t block[64]) { @@ -351,6 +351,8 @@ static int decode_p_block(FourXContext *f, uint16_t *dst, const uint16_t *src, index = size2index[log2h][log2w]; av_assert0(index >= 0); + if (get_bits_left(&f->gb) < 1) + return AVERROR_INVALIDDATA; h = 1 << log2h; code = get_vlc2(&f->gb, block_type_vlc[1 - (f->version > 1)][index].table, BLOCK_TYPE_VLC_BITS, 1); @@ -523,6 +525,10 @@ static int decode_i_block(FourXContext *f, int16_t *block) break; if (code == 0xf0) { i += 16; + if (i >= 64) { + av_log(f->avctx, AV_LOG_ERROR, "run %d overflow\n", i); + return 0; + } } else { if (code & 0xf) { level = get_xbits(&f->gb, code & 0xf); @@ -697,6 +703,7 @@ static const uint8_t *read_huffman_tables(FourXContext *f, len_tab[j] = len; } + ff_free_vlc(&f->pre_vlc); if (init_vlc(&f->pre_vlc, ACDC_VLC_BITS, 257, len_tab, 1, 1, bits_tab, 4, 4, 0)) return NULL;