libavcodec/wmv2dec.c:469: error: Buffer Overrun L3
  Offset: [1, +oo] Size: [0, +oo] by call to `ff_msmpeg4_decode_init`.

libavcodec/wmv2dec.c:469:8: Call
467.     }
468. 
469.     if(ff_msmpeg4_decode_init(avctx) < 0)
            ^
470.         return -1;
471. 

libavcodec/msmpeg4.c:1275:9: Global `rl_table.n`
  1273. 
  1274. /* init all vlc decoding tables */
  1275. av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx)
                ^
  1276. {
  1277.     MpegEncContext *s = avctx->priv_data;

libavcodec/msmpeg4.c:1292:9: Call
  1290.             init_rl(&rl_table[i], static_rl_table_store[i]);
  1291.         }
  1292.         INIT_VLC_RL(rl_table[0], 642);
                ^
  1293.         INIT_VLC_RL(rl_table[1], 1104);
  1294.         INIT_VLC_RL(rl_table[2], 554);

libavcodec/bitstream.c:272:1: Parameter `nb_codes`
    270.    with av_free_static(), 0 if free_vlc() will be used.
    271. */
    272. int init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes,
         ^
    273.              const void *bits, int bits_wrap, int bits_size,
    274.              const void *codes, int codes_wrap, int codes_size,

libavcodec/bitstream.c:278:17: Array declaration
    276.              int flags)
    277. {
    278.     VLCcode buf[nb_codes];
                         ^
    279.     int i, j;
    280. 

libavcodec/bitstream.c:322:9: Call
    320.     nb_codes = j;
    321. 
    322.     if (build_table(vlc, nb_bits, nb_codes, buf, flags) < 0) {
                 ^
    323.         av_freep(&vlc->table);
    324.         return -1;

libavcodec/bitstream.c:155:1: <Offset trace>
153.  *                       Sorting by VLCcode.code is sufficient, though not necessary.
154.  */
155. static int build_table(VLC *vlc, int table_nb_bits, int nb_codes,
     ^
156.                        VLCcode *codes, int flags)
157. {

libavcodec/bitstream.c:155:1: Parameter `nb_codes`
      153.  *                       Sorting by VLCcode.code is sufficient, though not necessary.
      154.  */
      155. static int build_table(VLC *vlc, int table_nb_bits, int nb_codes,
           ^
      156.                        VLCcode *codes, int flags)
      157. {

libavcodec/bitstream.c:155:1: <Length trace>
153.  *                       Sorting by VLCcode.code is sufficient, though not necessary.
154.  */
155. static int build_table(VLC *vlc, int table_nb_bits, int nb_codes,
     ^
156.                        VLCcode *codes, int flags)
157. {

libavcodec/bitstream.c:155:1: Parameter `*codes`
      153.  *                       Sorting by VLCcode.code is sufficient, though not necessary.
      154.  */
      155. static int build_table(VLC *vlc, int table_nb_bits, int nb_codes,
           ^
      156.                        VLCcode *codes, int flags)
      157. {

libavcodec/bitstream.c:216:21: Array access: Offset: [1, +oo] Size: [0, +oo] by call to `ff_msmpeg4_decode_init` 
      214.             codes[i].code = code << table_nb_bits;
      215.             for (k = i+1; k < nb_codes; k++) {
      216.                 n = codes[k].bits - table_nb_bits;
                               ^
      217.                 if (n <= 0)
      218.                     break;

static int build_table(VLC *vlc, int table_nb_bits, int nb_codes,
                       VLCcode *codes, int flags)
{
    int table_size, table_index, index, code_prefix, symbol, subtable_bits;
    int i, j, k, n, nb, inc;
    uint32_t code;
    VLC_TYPE (*table)[2];
    table_size = 1 << table_nb_bits;
    table_index = alloc_table(vlc, table_size, flags & INIT_VLC_USE_NEW_STATIC);
#ifdef DEBUG_VLC
    av_log(NULL,AV_LOG_DEBUG,"new table index=%d size=%d\n",
           table_index, table_size);
#endif
    if (table_index < 0)
        return -1;
    table = &vlc->table[table_index];
    for (i = 0; i < table_size; i++) {
        table[i][1] = 0;
        table[i][0] = -1;
    }
    for (i = 0; i < nb_codes; i++) {
        n = codes[i].bits;
        code = codes[i].code;
        symbol = codes[i].symbol;
#if defined(DEBUG_VLC) && 0
        av_log(NULL,AV_LOG_DEBUG,"i=%d n=%d code=0x%x\n", i, n, code);
#endif
        if (n <= table_nb_bits) {
            j = code >> (32 - table_nb_bits);
            nb = 1 << (table_nb_bits - n);
            inc = 1;
            if (flags & INIT_VLC_LE) {
                j = bitswap_32(code);
                inc = 1 << n;
            }
            for (k = 0; k < nb; k++) {
#ifdef DEBUG_VLC
                av_log(NULL, AV_LOG_DEBUG, "%4x: code=%d n=%d\n",
                       j, i, n);
#endif
                if (table[j][1]   != 0) {
                    av_log(NULL, AV_LOG_ERROR, "incorrect codes\n");
                    return -1;
                }
                table[j][1] = n;
                table[j][0] = symbol;
                j += inc;
            }
        } else {
            n -= table_nb_bits;
            code_prefix = code >> (32 - table_nb_bits);
            subtable_bits = n;
            codes[i].bits = n;
            codes[i].code = code << table_nb_bits;
            for (k = i+1; k < nb_codes; k++) {
                n = codes[k].bits - table_nb_bits;
                if (n <= 0)
                    break;
                code = codes[k].code;
                if (code >> (32 - table_nb_bits) != code_prefix)
                    break;
                codes[k].bits = n;
                codes[k].code = code << table_nb_bits;
                subtable_bits = FFMAX(subtable_bits, n);
            }
            subtable_bits = FFMIN(subtable_bits, table_nb_bits);
            j = (flags & INIT_VLC_LE) ? bitswap_32(code_prefix) >> (32 - table_nb_bits) : code_prefix;
            table[j][1] = -subtable_bits;
#ifdef DEBUG_VLC
            av_log(NULL,AV_LOG_DEBUG,"%4x: n=%d (subtable)\n",
                   j, codes[i].bits + table_nb_bits);
#endif
            index = build_table(vlc, subtable_bits, k-i, codes+i, flags);
            if (index < 0)
                return -1;
            table = &vlc->table[table_index];
            table[j][0] = index;
            i = k-1;
        }
    }
    return table_index;
}
['static av_cold int wmv2_decode_init(AVCodecContext *avctx){\n    Wmv2Context * const w= avctx->priv_data;\n    if(avctx->idct_algo==FF_IDCT_AUTO){\n        avctx->idct_algo=FF_IDCT_WMV2;\n    }\n    if(ff_msmpeg4_decode_init(avctx) < 0)\n        return -1;\n    ff_wmv2_common_init(w);\n    ff_intrax8_common_init(&w->x8,&w->s);\n    return 0;\n}', 'int ff_msmpeg4_decode_init(AVCodecContext *avctx)\n{\n    MpegEncContext *s = avctx->priv_data;\n    static int done = 0;\n    int i;\n    MVTable *mv;\n    ff_h263_decode_init(avctx);\n    common_init(s);\n    if (!done) {\n        done = 1;\n        for(i=0;i<NB_RL_TABLES;i++) {\n            init_rl(&rl_table[i], static_rl_table_store[i]);\n        }\n        INIT_VLC_RL(rl_table[0], 642);\n        INIT_VLC_RL(rl_table[1], 1104);\n        INIT_VLC_RL(rl_table[2], 554);\n        INIT_VLC_RL(rl_table[3], 940);\n        INIT_VLC_RL(rl_table[4], 962);\n        INIT_VLC_RL(rl_table[5], 554);\n        mv = &mv_tables[0];\n        INIT_VLC_STATIC(&mv->vlc, MV_VLC_BITS, mv->n + 1,\n                    mv->table_mv_bits, 1, 1,\n                    mv->table_mv_code, 2, 2, 3714);\n        mv = &mv_tables[1];\n        INIT_VLC_STATIC(&mv->vlc, MV_VLC_BITS, mv->n + 1,\n                    mv->table_mv_bits, 1, 1,\n                    mv->table_mv_code, 2, 2, 2694);\n        INIT_VLC_STATIC(&ff_msmp4_dc_luma_vlc[0], DC_VLC_BITS, 120,\n                 &ff_table0_dc_lum[0][1], 8, 4,\n                 &ff_table0_dc_lum[0][0], 8, 4, 1158);\n        INIT_VLC_STATIC(&ff_msmp4_dc_chroma_vlc[0], DC_VLC_BITS, 120,\n                 &ff_table0_dc_chroma[0][1], 8, 4,\n                 &ff_table0_dc_chroma[0][0], 8, 4, 1118);\n        INIT_VLC_STATIC(&ff_msmp4_dc_luma_vlc[1], DC_VLC_BITS, 120,\n                 &ff_table1_dc_lum[0][1], 8, 4,\n                 &ff_table1_dc_lum[0][0], 8, 4, 1476);\n        INIT_VLC_STATIC(&ff_msmp4_dc_chroma_vlc[1], DC_VLC_BITS, 120,\n                 &ff_table1_dc_chroma[0][1], 8, 4,\n                 &ff_table1_dc_chroma[0][0], 8, 4, 1216);\n        INIT_VLC_STATIC(&v2_dc_lum_vlc, DC_VLC_BITS, 512,\n                 &v2_dc_lum_table[0][1], 8, 4,\n                 &v2_dc_lum_table[0][0], 8, 4, 1472);\n        INIT_VLC_STATIC(&v2_dc_chroma_vlc, DC_VLC_BITS, 512,\n                 &v2_dc_chroma_table[0][1], 8, 4,\n                 &v2_dc_chroma_table[0][0], 8, 4, 1506);\n        INIT_VLC_STATIC(&v2_intra_cbpc_vlc, V2_INTRA_CBPC_VLC_BITS, 4,\n                 &v2_intra_cbpc[0][1], 2, 1,\n                 &v2_intra_cbpc[0][0], 2, 1, 8);\n        INIT_VLC_STATIC(&v2_mb_type_vlc, V2_MB_TYPE_VLC_BITS, 8,\n                 &v2_mb_type[0][1], 2, 1,\n                 &v2_mb_type[0][0], 2, 1, 128);\n        INIT_VLC_STATIC(&v2_mv_vlc, V2_MV_VLC_BITS, 33,\n                 &mvtab[0][1], 2, 1,\n                 &mvtab[0][0], 2, 1, 538);\n        INIT_VLC_STATIC(&ff_mb_non_intra_vlc[0], MB_NON_INTRA_VLC_BITS, 128,\n                     &wmv2_inter_table[0][0][1], 8, 4,\n                     &wmv2_inter_table[0][0][0], 8, 4, 1636);\n        INIT_VLC_STATIC(&ff_mb_non_intra_vlc[1], MB_NON_INTRA_VLC_BITS, 128,\n                     &wmv2_inter_table[1][0][1], 8, 4,\n                     &wmv2_inter_table[1][0][0], 8, 4, 2648);\n        INIT_VLC_STATIC(&ff_mb_non_intra_vlc[2], MB_NON_INTRA_VLC_BITS, 128,\n                     &wmv2_inter_table[2][0][1], 8, 4,\n                     &wmv2_inter_table[2][0][0], 8, 4, 1532);\n        INIT_VLC_STATIC(&ff_mb_non_intra_vlc[3], MB_NON_INTRA_VLC_BITS, 128,\n                     &wmv2_inter_table[3][0][1], 8, 4,\n                     &wmv2_inter_table[3][0][0], 8, 4, 2488);\n        INIT_VLC_STATIC(&ff_msmp4_mb_i_vlc, MB_INTRA_VLC_BITS, 64,\n                 &ff_msmp4_mb_i_table[0][1], 4, 2,\n                 &ff_msmp4_mb_i_table[0][0], 4, 2, 536);\n        INIT_VLC_STATIC(&ff_inter_intra_vlc, INTER_INTRA_VLC_BITS, 4,\n                 &table_inter_intra[0][1], 2, 1,\n                 &table_inter_intra[0][0], 2, 1, 8);\n    }\n    switch(s->msmpeg4_version){\n    case 1:\n    case 2:\n        s->decode_mb= msmpeg4v12_decode_mb;\n        break;\n    case 3:\n    case 4:\n        s->decode_mb= msmpeg4v34_decode_mb;\n        break;\n    case 5:\n        if (CONFIG_WMV2_DECODER)\n            s->decode_mb= ff_wmv2_decode_mb;\n    case 6:\n        break;\n    }\n    s->slice_height= s->mb_height;\n    return 0;\n}', 'int init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes,\n             const void *bits, int bits_wrap, int bits_size,\n             const void *codes, int codes_wrap, int codes_size,\n             const void *symbols, int symbols_wrap, int symbols_size,\n             int flags)\n{\n    VLCcode buf[nb_codes];\n    int i, j;\n    vlc->bits = nb_bits;\n    if(flags & INIT_VLC_USE_NEW_STATIC){\n        if(vlc->table_size && vlc->table_size == vlc->table_allocated){\n            return 0;\n        }else if(vlc->table_size){\n            abort();\n        }\n    }else {\n        vlc->table = NULL;\n        vlc->table_allocated = 0;\n        vlc->table_size = 0;\n    }\n#ifdef DEBUG_VLC\n    av_log(NULL,AV_LOG_DEBUG,"build table nb_codes=%d\\n", nb_codes);\n#endif\n    assert(symbols_size <= 2 || !symbols);\n    j = 0;\n#define COPY(condition)\\\n    for (i = 0; i < nb_codes; i++) {\\\n        GET_DATA(buf[j].bits, bits, i, bits_wrap, bits_size);\\\n        if (!(condition))\\\n            continue;\\\n        GET_DATA(buf[j].code, codes, i, codes_wrap, codes_size);\\\n        if (flags & INIT_VLC_LE)\\\n            buf[j].code = bitswap_32(buf[j].code);\\\n        else\\\n            buf[j].code <<= 32 - buf[j].bits;\\\n        if (symbols)\\\n            GET_DATA(buf[j].symbol, symbols, i, symbols_wrap, symbols_size)\\\n        else\\\n            buf[j].symbol = i;\\\n        j++;\\\n    }\n    COPY(buf[j].bits > nb_bits);\n    qsort(buf, j, sizeof(VLCcode), compare_vlcspec);\n    COPY(buf[j].bits && buf[j].bits <= nb_bits);\n    nb_codes = j;\n    if (build_table(vlc, nb_bits, nb_codes, buf, flags) < 0) {\n        av_freep(&vlc->table);\n        return -1;\n    }\n    if((flags & INIT_VLC_USE_NEW_STATIC) && vlc->table_size != vlc->table_allocated)\n        av_log(NULL, AV_LOG_ERROR, "needed %d had %d\\n", vlc->table_size, vlc->table_allocated);\n    return 0;\n}', 'static int build_table(VLC *vlc, int table_nb_bits, int nb_codes,\n                       VLCcode *codes, int flags)\n{\n    int table_size, table_index, index, code_prefix, symbol, subtable_bits;\n    int i, j, k, n, nb, inc;\n    uint32_t code;\n    VLC_TYPE (*table)[2];\n    table_size = 1 << table_nb_bits;\n    table_index = alloc_table(vlc, table_size, flags & INIT_VLC_USE_NEW_STATIC);\n#ifdef DEBUG_VLC\n    av_log(NULL,AV_LOG_DEBUG,"new table index=%d size=%d\\n",\n           table_index, table_size);\n#endif\n    if (table_index < 0)\n        return -1;\n    table = &vlc->table[table_index];\n    for (i = 0; i < table_size; i++) {\n        table[i][1] = 0;\n        table[i][0] = -1;\n    }\n    for (i = 0; i < nb_codes; i++) {\n        n = codes[i].bits;\n        code = codes[i].code;\n        symbol = codes[i].symbol;\n#if defined(DEBUG_VLC) && 0\n        av_log(NULL,AV_LOG_DEBUG,"i=%d n=%d code=0x%x\\n", i, n, code);\n#endif\n        if (n <= table_nb_bits) {\n            j = code >> (32 - table_nb_bits);\n            nb = 1 << (table_nb_bits - n);\n            inc = 1;\n            if (flags & INIT_VLC_LE) {\n                j = bitswap_32(code);\n                inc = 1 << n;\n            }\n            for (k = 0; k < nb; k++) {\n#ifdef DEBUG_VLC\n                av_log(NULL, AV_LOG_DEBUG, "%4x: code=%d n=%d\\n",\n                       j, i, n);\n#endif\n                if (table[j][1]   != 0) {\n                    av_log(NULL, AV_LOG_ERROR, "incorrect codes\\n");\n                    return -1;\n                }\n                table[j][1] = n;\n                table[j][0] = symbol;\n                j += inc;\n            }\n        } else {\n            n -= table_nb_bits;\n            code_prefix = code >> (32 - table_nb_bits);\n            subtable_bits = n;\n            codes[i].bits = n;\n            codes[i].code = code << table_nb_bits;\n            for (k = i+1; k < nb_codes; k++) {\n                n = codes[k].bits - table_nb_bits;\n                if (n <= 0)\n                    break;\n                code = codes[k].code;\n                if (code >> (32 - table_nb_bits) != code_prefix)\n                    break;\n                codes[k].bits = n;\n                codes[k].code = code << table_nb_bits;\n                subtable_bits = FFMAX(subtable_bits, n);\n            }\n            subtable_bits = FFMIN(subtable_bits, table_nb_bits);\n            j = (flags & INIT_VLC_LE) ? bitswap_32(code_prefix) >> (32 - table_nb_bits) : code_prefix;\n            table[j][1] = -subtable_bits;\n#ifdef DEBUG_VLC\n            av_log(NULL,AV_LOG_DEBUG,"%4x: n=%d (subtable)\\n",\n                   j, codes[i].bits + table_nb_bits);\n#endif\n            index = build_table(vlc, subtable_bits, k-i, codes+i, flags);\n            if (index < 0)\n                return -1;\n            table = &vlc->table[table_index];\n            table[j][0] = index;\n            i = k-1;\n        }\n    }\n    return table_index;\n}']