libavcodec/adpcm.c:427: error: Buffer Overrun L2
  Offset: [0, 2] Size: 2.

libavcodec/adpcm.c:288:28: <Length trace>
286.     TrellisPath paths[max_paths], *p;
287.     TrellisNode node_buf[2][frontier];
288.     TrellisNode *nodep_buf[2][frontier];
                                ^
289.     TrellisNode **nodes = nodep_buf[0]; // nodes[] is always sorted by .ssd
290.     TrellisNode **nodes_next = nodep_buf[1];

libavcodec/adpcm.c:288:28: Array declaration
286.     TrellisPath paths[max_paths], *p;
287.     TrellisNode node_buf[2][frontier];
288.     TrellisNode *nodep_buf[2][frontier];
                                ^
289.     TrellisNode **nodes = nodep_buf[0]; // nodes[] is always sorted by .ssd
290.     TrellisNode **nodes_next = nodep_buf[1];

libavcodec/adpcm.c:289:5: Assignment
287.     TrellisNode node_buf[2][frontier];
288.     TrellisNode *nodep_buf[2][frontier];
289.     TrellisNode **nodes = nodep_buf[0]; // nodes[] is always sorted by .ssd
         ^
290.     TrellisNode **nodes_next = nodep_buf[1];
291.     int pathn = 0, froze = -1, i, j, k;

libavcodec/adpcm.c:427:20: Array access: Offset: [0, 2] Size: 2
425.     }
426. 
427.     c->predictor = nodes[0]->sample1;
                        ^
428.     c->sample1 = nodes[0]->sample1;
429.     c->sample2 = nodes[0]->sample2;

static void adpcm_compress_trellis(AVCodecContext *avctx, const short *samples,
                                   uint8_t *dst, ADPCMChannelStatus *c, int n)
{
#define FREEZE_INTERVAL 128
    const int frontier = 1 << avctx->trellis;
    const int stride = avctx->channels;
    const int version = avctx->codec->id;
    const int max_paths = frontier*FREEZE_INTERVAL;
    TrellisPath paths[max_paths], *p;
    TrellisNode node_buf[2][frontier];
    TrellisNode *nodep_buf[2][frontier];
    TrellisNode **nodes = nodep_buf[0];
    TrellisNode **nodes_next = nodep_buf[1];
    int pathn = 0, froze = -1, i, j, k;
    assert(!(max_paths&(max_paths-1)));
    memset(nodep_buf, 0, sizeof(nodep_buf));
    nodes[0] = &node_buf[1][0];
    nodes[0]->ssd = 0;
    nodes[0]->path = 0;
    nodes[0]->step = c->step_index;
    nodes[0]->sample1 = c->sample1;
    nodes[0]->sample2 = c->sample2;
    if((version == CODEC_ID_ADPCM_IMA_WAV) || (version == CODEC_ID_ADPCM_IMA_QT) || (version == CODEC_ID_ADPCM_SWF))
        nodes[0]->sample1 = c->prev_sample;
    if(version == CODEC_ID_ADPCM_MS)
        nodes[0]->step = c->idelta;
    if(version == CODEC_ID_ADPCM_YAMAHA) {
        if(c->step == 0) {
            nodes[0]->step = 127;
            nodes[0]->sample1 = 0;
        } else {
            nodes[0]->step = c->step;
            nodes[0]->sample1 = c->predictor;
        }
    }
    for(i=0; i<n; i++) {
        TrellisNode *t = node_buf[i&1];
        TrellisNode **u;
        int sample = samples[i*stride];
        memset(nodes_next, 0, frontier*sizeof(TrellisNode*));
        for(j=0; j<frontier && nodes[j]; j++) {
            const int range = (j < frontier/2) ? 1 : 0;
            const int step = nodes[j]->step;
            int nidx;
            if(version == CODEC_ID_ADPCM_MS) {
                const int predictor = ((nodes[j]->sample1 * c->coeff1) + (nodes[j]->sample2 * c->coeff2)) / 256;
                const int div = (sample - predictor) / step;
                const int nmin = av_clip(div-range, -8, 6);
                const int nmax = av_clip(div+range, -7, 7);
                for(nidx=nmin; nidx<=nmax; nidx++) {
                    const int nibble = nidx & 0xf;
                    int dec_sample = predictor + nidx * step;
#define STORE_NODE(NAME, STEP_INDEX)\
                    int d;\
                    uint32_t ssd;\
                    dec_sample = av_clip_int16(dec_sample);\
                    d = sample - dec_sample;\
                    ssd = nodes[j]->ssd + d*d;\
                    if(nodes_next[frontier-1] && ssd >= nodes_next[frontier-1]->ssd)\
                        continue;\
                     \
                    for(k=0; k<frontier && nodes_next[k]; k++) {\
                        if(dec_sample == nodes_next[k]->sample1) {\
                            assert(ssd >= nodes_next[k]->ssd);\
                            goto next_##NAME;\
                        }\
                    }\
                    for(k=0; k<frontier; k++) {\
                        if(!nodes_next[k] || ssd < nodes_next[k]->ssd) {\
                            TrellisNode *u = nodes_next[frontier-1];\
                            if(!u) {\
                                assert(pathn < max_paths);\
                                u = t++;\
                                u->path = pathn++;\
                            }\
                            u->ssd = ssd;\
                            u->step = STEP_INDEX;\
                            u->sample2 = nodes[j]->sample1;\
                            u->sample1 = dec_sample;\
                            paths[u->path].nibble = nibble;\
                            paths[u->path].prev = nodes[j]->path;\
                            memmove(&nodes_next[k+1], &nodes_next[k], (frontier-k-1)*sizeof(TrellisNode*));\
                            nodes_next[k] = u;\
                            break;\
                        }\
                    }\
                    next_##NAME:;
                    STORE_NODE(ms, FFMAX(16, (AdaptationTable[nibble] * step) >> 8));
                }
            } else if((version == CODEC_ID_ADPCM_IMA_WAV)|| (version == CODEC_ID_ADPCM_IMA_QT)|| (version == CODEC_ID_ADPCM_SWF)) {
#define LOOP_NODES(NAME, STEP_TABLE, STEP_INDEX)\
                const int predictor = nodes[j]->sample1;\
                const int div = (sample - predictor) * 4 / STEP_TABLE;\
                int nmin = av_clip(div-range, -7, 6);\
                int nmax = av_clip(div+range, -6, 7);\
                if(nmin<=0) nmin--;  \
                if(nmax<0) nmax--;\
                for(nidx=nmin; nidx<=nmax; nidx++) {\
                    const int nibble = nidx<0 ? 7-nidx : nidx;\
                    int dec_sample = predictor + (STEP_TABLE * yamaha_difflookup[nibble]) / 8;\
                    STORE_NODE(NAME, STEP_INDEX);\
                }
                LOOP_NODES(ima, step_table[step], av_clip(step + index_table[nibble], 0, 88));
            } else {
                LOOP_NODES(yamaha, step, av_clip((step * yamaha_indexscale[nibble]) >> 8, 127, 24567));
#undef LOOP_NODES
#undef STORE_NODE
            }
        }
        u = nodes;
        nodes = nodes_next;
        nodes_next = u;
        if(nodes[0]->ssd > (1<<28)) {
            for(j=1; j<frontier && nodes[j]; j++)
                nodes[j]->ssd -= nodes[0]->ssd;
            nodes[0]->ssd = 0;
        }
        if(i == froze + FREEZE_INTERVAL) {
            p = &paths[nodes[0]->path];
            for(k=i; k>froze; k--) {
                dst[k] = p->nibble;
                p = &paths[p->prev];
            }
            froze = i;
            pathn = 0;
            memset(nodes+1, 0, (frontier-1)*sizeof(TrellisNode*));
        }
    }
    p = &paths[nodes[0]->path];
    for(i=n-1; i>froze; i--) {
        dst[i] = p->nibble;
        p = &paths[p->prev];
    }
    c->predictor = nodes[0]->sample1;
    c->sample1 = nodes[0]->sample1;
    c->sample2 = nodes[0]->sample2;
    c->step_index = nodes[0]->step;
    c->step = nodes[0]->step;
    c->idelta = nodes[0]->step;
}
['static void adpcm_compress_trellis(AVCodecContext *avctx, const short *samples,\n                                   uint8_t *dst, ADPCMChannelStatus *c, int n)\n{\n#define FREEZE_INTERVAL 128\n    const int frontier = 1 << avctx->trellis;\n    const int stride = avctx->channels;\n    const int version = avctx->codec->id;\n    const int max_paths = frontier*FREEZE_INTERVAL;\n    TrellisPath paths[max_paths], *p;\n    TrellisNode node_buf[2][frontier];\n    TrellisNode *nodep_buf[2][frontier];\n    TrellisNode **nodes = nodep_buf[0];\n    TrellisNode **nodes_next = nodep_buf[1];\n    int pathn = 0, froze = -1, i, j, k;\n    assert(!(max_paths&(max_paths-1)));\n    memset(nodep_buf, 0, sizeof(nodep_buf));\n    nodes[0] = &node_buf[1][0];\n    nodes[0]->ssd = 0;\n    nodes[0]->path = 0;\n    nodes[0]->step = c->step_index;\n    nodes[0]->sample1 = c->sample1;\n    nodes[0]->sample2 = c->sample2;\n    if((version == CODEC_ID_ADPCM_IMA_WAV) || (version == CODEC_ID_ADPCM_IMA_QT) || (version == CODEC_ID_ADPCM_SWF))\n        nodes[0]->sample1 = c->prev_sample;\n    if(version == CODEC_ID_ADPCM_MS)\n        nodes[0]->step = c->idelta;\n    if(version == CODEC_ID_ADPCM_YAMAHA) {\n        if(c->step == 0) {\n            nodes[0]->step = 127;\n            nodes[0]->sample1 = 0;\n        } else {\n            nodes[0]->step = c->step;\n            nodes[0]->sample1 = c->predictor;\n        }\n    }\n    for(i=0; i<n; i++) {\n        TrellisNode *t = node_buf[i&1];\n        TrellisNode **u;\n        int sample = samples[i*stride];\n        memset(nodes_next, 0, frontier*sizeof(TrellisNode*));\n        for(j=0; j<frontier && nodes[j]; j++) {\n            const int range = (j < frontier/2) ? 1 : 0;\n            const int step = nodes[j]->step;\n            int nidx;\n            if(version == CODEC_ID_ADPCM_MS) {\n                const int predictor = ((nodes[j]->sample1 * c->coeff1) + (nodes[j]->sample2 * c->coeff2)) / 256;\n                const int div = (sample - predictor) / step;\n                const int nmin = av_clip(div-range, -8, 6);\n                const int nmax = av_clip(div+range, -7, 7);\n                for(nidx=nmin; nidx<=nmax; nidx++) {\n                    const int nibble = nidx & 0xf;\n                    int dec_sample = predictor + nidx * step;\n#define STORE_NODE(NAME, STEP_INDEX)\\\n                    int d;\\\n                    uint32_t ssd;\\\n                    dec_sample = av_clip_int16(dec_sample);\\\n                    d = sample - dec_sample;\\\n                    ssd = nodes[j]->ssd + d*d;\\\n                    if(nodes_next[frontier-1] && ssd >= nodes_next[frontier-1]->ssd)\\\n                        continue;\\\n                     \\\n                    for(k=0; k<frontier && nodes_next[k]; k++) {\\\n                        if(dec_sample == nodes_next[k]->sample1) {\\\n                            assert(ssd >= nodes_next[k]->ssd);\\\n                            goto next_##NAME;\\\n                        }\\\n                    }\\\n                    for(k=0; k<frontier; k++) {\\\n                        if(!nodes_next[k] || ssd < nodes_next[k]->ssd) {\\\n                            TrellisNode *u = nodes_next[frontier-1];\\\n                            if(!u) {\\\n                                assert(pathn < max_paths);\\\n                                u = t++;\\\n                                u->path = pathn++;\\\n                            }\\\n                            u->ssd = ssd;\\\n                            u->step = STEP_INDEX;\\\n                            u->sample2 = nodes[j]->sample1;\\\n                            u->sample1 = dec_sample;\\\n                            paths[u->path].nibble = nibble;\\\n                            paths[u->path].prev = nodes[j]->path;\\\n                            memmove(&nodes_next[k+1], &nodes_next[k], (frontier-k-1)*sizeof(TrellisNode*));\\\n                            nodes_next[k] = u;\\\n                            break;\\\n                        }\\\n                    }\\\n                    next_##NAME:;\n                    STORE_NODE(ms, FFMAX(16, (AdaptationTable[nibble] * step) >> 8));\n                }\n            } else if((version == CODEC_ID_ADPCM_IMA_WAV)|| (version == CODEC_ID_ADPCM_IMA_QT)|| (version == CODEC_ID_ADPCM_SWF)) {\n#define LOOP_NODES(NAME, STEP_TABLE, STEP_INDEX)\\\n                const int predictor = nodes[j]->sample1;\\\n                const int div = (sample - predictor) * 4 / STEP_TABLE;\\\n                int nmin = av_clip(div-range, -7, 6);\\\n                int nmax = av_clip(div+range, -6, 7);\\\n                if(nmin<=0) nmin--;  \\\n                if(nmax<0) nmax--;\\\n                for(nidx=nmin; nidx<=nmax; nidx++) {\\\n                    const int nibble = nidx<0 ? 7-nidx : nidx;\\\n                    int dec_sample = predictor + (STEP_TABLE * yamaha_difflookup[nibble]) / 8;\\\n                    STORE_NODE(NAME, STEP_INDEX);\\\n                }\n                LOOP_NODES(ima, step_table[step], av_clip(step + index_table[nibble], 0, 88));\n            } else {\n                LOOP_NODES(yamaha, step, av_clip((step * yamaha_indexscale[nibble]) >> 8, 127, 24567));\n#undef LOOP_NODES\n#undef STORE_NODE\n            }\n        }\n        u = nodes;\n        nodes = nodes_next;\n        nodes_next = u;\n        if(nodes[0]->ssd > (1<<28)) {\n            for(j=1; j<frontier && nodes[j]; j++)\n                nodes[j]->ssd -= nodes[0]->ssd;\n            nodes[0]->ssd = 0;\n        }\n        if(i == froze + FREEZE_INTERVAL) {\n            p = &paths[nodes[0]->path];\n            for(k=i; k>froze; k--) {\n                dst[k] = p->nibble;\n                p = &paths[p->prev];\n            }\n            froze = i;\n            pathn = 0;\n            memset(nodes+1, 0, (frontier-1)*sizeof(TrellisNode*));\n        }\n    }\n    p = &paths[nodes[0]->path];\n    for(i=n-1; i>froze; i--) {\n        dst[i] = p->nibble;\n        p = &paths[p->prev];\n    }\n    c->predictor = nodes[0]->sample1;\n    c->sample1 = nodes[0]->sample1;\n    c->sample2 = nodes[0]->sample2;\n    c->step_index = nodes[0]->step;\n    c->step = nodes[0]->step;\n    c->idelta = nodes[0]->step;\n}']