libavcodec/dnxhddec.c:74: error: Buffer Overrun L3
  Offset: [1, +oo] Size: [0, +oo] by call to `init_vlc_sparse`.

libavcodec/dnxhddec.c:74:9: Call
72.                  ctx->cid_table->ac_bits, 1, 1,
73.                  ctx->cid_table->ac_codes, 2, 2, 0);
74.         init_vlc(&ctx->dc_vlc, DNXHD_DC_VLC_BITS, ctx->cid_table->bit_depth+4,
            ^
75.                  ctx->cid_table->dc_bits, 1, 1,
76.                  ctx->cid_table->dc_codes, 1, 1, 0);

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 `init_vlc_sparse` 
    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 int dnxhd_init_vlc(DNXHDContext *ctx, int cid)\n{\n    if (!ctx->cid_table) {\n        int index;\n        if ((index = ff_dnxhd_get_cid_table(cid)) < 0) {\n            av_log(ctx->avctx, AV_LOG_ERROR, "unsupported cid %d\\n", cid);\n            return -1;\n        }\n        ctx->cid_table = &ff_dnxhd_cid_table[index];\n        init_vlc(&ctx->ac_vlc, DNXHD_VLC_BITS, 257,\n                 ctx->cid_table->ac_bits, 1, 1,\n                 ctx->cid_table->ac_codes, 2, 2, 0);\n        init_vlc(&ctx->dc_vlc, DNXHD_DC_VLC_BITS, ctx->cid_table->bit_depth+4,\n                 ctx->cid_table->dc_bits, 1, 1,\n                 ctx->cid_table->dc_codes, 1, 1, 0);\n        init_vlc(&ctx->run_vlc, DNXHD_VLC_BITS, 62,\n                 ctx->cid_table->run_bits, 1, 1,\n                 ctx->cid_table->run_codes, 2, 2, 0);\n        ff_init_scantable(ctx->dsp.idct_permutation, &ctx->scantable, ff_zigzag_direct);\n    }\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}']