libavcodec/hevc.c:3119: error: Buffer Overrun L1
  Offset: -1 Size: 7 by call to `set_sps`.

libavcodec/hevc.c:3092:9: Call
3090. 
3091.     for (i = 0; i < FF_ARRAY_ELEMS(s->vps_list); i++) {
3092.         av_buffer_unref(&s->vps_list[i]);
              ^
3093.         if (s0->vps_list[i]) {
3094.             s->vps_list[i] = av_buffer_ref(s0->vps_list[i]);

libavutil/buffer.c:106:1: Parameter `**buf`
  104. }
  105. 
  106. void av_buffer_unref(AVBufferRef **buf)
       ^
  107. {
  108.     AVBuffer *b;

libavcodec/hevc.c:3119:15: Call
3117. 
3118.     if (s->sps != s0->sps)
3119.         ret = set_sps(s, s0->sps);
                    ^
3120. 
3121.     s->seq_decode = s0->seq_decode;

libavcodec/hevc.c:432:1: Parameter `sps->max_sub_layers`
  430. }
  431. 
  432. static int set_sps(HEVCContext *s, const HEVCSPS *sps)
       ^
  433. {
  434.     #define HWACCEL_MAX (CONFIG_HEVC_DXVA2_HWACCEL)

libavcodec/hevc.c:438:5: Call
  436.     int ret;
  437. 
  438.     export_stream_params(s->avctx, s, sps);
           ^
  439. 
  440.     pic_arrays_free(s);

libavcodec/hevc.c:386:1: <Offset trace>
384. }
385. 
386. static void export_stream_params(AVCodecContext *avctx,
     ^
387.                                  const HEVCContext *s, const HEVCSPS *sps)
388. {

libavcodec/hevc.c:386:1: Parameter `sps->max_sub_layers`
    384. }
    385. 
    386. static void export_stream_params(AVCodecContext *avctx,
         ^
    387.                                  const HEVCContext *s, const HEVCSPS *sps)
    388. {

libavcodec/hevc.c:386:1: <Length trace>
384. }
385. 
386. static void export_stream_params(AVCodecContext *avctx,
     ^
387.                                  const HEVCContext *s, const HEVCSPS *sps)
388. {

libavcodec/hevc.c:386:1: Parameter `sps->temporal_layer[*]`
    384. }
    385. 
    386. static void export_stream_params(AVCodecContext *avctx,
         ^
    387.                                  const HEVCContext *s, const HEVCSPS *sps)
    388. {

libavcodec/hevc.c:397:34: Array access: Offset: -1 Size: 7 by call to `set_sps` 
    395.     avctx->width               = sps->output_width;
    396.     avctx->height              = sps->output_height;
    397.     avctx->has_b_frames        = sps->temporal_layer[sps->max_sub_layers - 1].num_reorder_pics;
                                          ^
    398.     avctx->profile             = sps->ptl.general_ptl.profile_idc;
    399.     avctx->level               = sps->ptl.general_ptl.level_idc;

static void export_stream_params(AVCodecContext *avctx,
                                 const HEVCContext *s, const HEVCSPS *sps)
{
    const HEVCVPS *vps = (const HEVCVPS*)s->vps_list[sps->vps_id]->data;
    unsigned int num = 0, den = 0;
    avctx->pix_fmt             = sps->pix_fmt;
    avctx->coded_width         = sps->width;
    avctx->coded_height        = sps->height;
    avctx->width               = sps->output_width;
    avctx->height              = sps->output_height;
    avctx->has_b_frames        = sps->temporal_layer[sps->max_sub_layers - 1].num_reorder_pics;
    avctx->profile             = sps->ptl.general_ptl.profile_idc;
    avctx->level               = sps->ptl.general_ptl.level_idc;
    ff_set_sar(avctx, sps->vui.sar);
    if (sps->vui.video_signal_type_present_flag)
        avctx->color_range = sps->vui.video_full_range_flag ? AVCOL_RANGE_JPEG
                                                            : AVCOL_RANGE_MPEG;
    else
        avctx->color_range = AVCOL_RANGE_MPEG;
    if (sps->vui.colour_description_present_flag) {
        avctx->color_primaries = sps->vui.colour_primaries;
        avctx->color_trc       = sps->vui.transfer_characteristic;
        avctx->colorspace      = sps->vui.matrix_coeffs;
    } else {
        avctx->color_primaries = AVCOL_PRI_UNSPECIFIED;
        avctx->color_trc       = AVCOL_TRC_UNSPECIFIED;
        avctx->colorspace      = AVCOL_SPC_UNSPECIFIED;
    }
    if (vps->vps_timing_info_present_flag) {
        num = vps->vps_num_units_in_tick;
        den = vps->vps_time_scale;
    } else if (sps->vui.vui_timing_info_present_flag) {
        num = sps->vui.vui_num_units_in_tick;
        den = sps->vui.vui_time_scale;
    }
    if (num != 0 && den != 0)
        av_reduce(&avctx->framerate.den, &avctx->framerate.num,
                  num, den, 1 << 30);
}
['static int hevc_update_thread_context(AVCodecContext *dst,\n                                      const AVCodecContext *src)\n{\n    HEVCContext *s  = dst->priv_data;\n    HEVCContext *s0 = src->priv_data;\n    int i, ret;\n    if (!s->context_initialized) {\n        ret = hevc_init_context(dst);\n        if (ret < 0)\n            return ret;\n    }\n    for (i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++) {\n        ff_hevc_unref_frame(s, &s->DPB[i], ~0);\n        if (s0->DPB[i].frame->buf[0]) {\n            ret = hevc_ref_frame(s, &s->DPB[i], &s0->DPB[i]);\n            if (ret < 0)\n                return ret;\n        }\n    }\n    for (i = 0; i < FF_ARRAY_ELEMS(s->vps_list); i++) {\n        av_buffer_unref(&s->vps_list[i]);\n        if (s0->vps_list[i]) {\n            s->vps_list[i] = av_buffer_ref(s0->vps_list[i]);\n            if (!s->vps_list[i])\n                return AVERROR(ENOMEM);\n        }\n    }\n    for (i = 0; i < FF_ARRAY_ELEMS(s->sps_list); i++) {\n        av_buffer_unref(&s->sps_list[i]);\n        if (s0->sps_list[i]) {\n            s->sps_list[i] = av_buffer_ref(s0->sps_list[i]);\n            if (!s->sps_list[i])\n                return AVERROR(ENOMEM);\n        }\n    }\n    for (i = 0; i < FF_ARRAY_ELEMS(s->pps_list); i++) {\n        av_buffer_unref(&s->pps_list[i]);\n        if (s0->pps_list[i]) {\n            s->pps_list[i] = av_buffer_ref(s0->pps_list[i]);\n            if (!s->pps_list[i])\n                return AVERROR(ENOMEM);\n        }\n    }\n    if (s->sps != s0->sps)\n        ret = set_sps(s, s0->sps);\n    s->seq_decode = s0->seq_decode;\n    s->seq_output = s0->seq_output;\n    s->pocTid0    = s0->pocTid0;\n    s->max_ra     = s0->max_ra;\n    s->is_nalff        = s0->is_nalff;\n    s->nal_length_size = s0->nal_length_size;\n    if (s0->eos) {\n        s->seq_decode = (s->seq_decode + 1) & 0xff;\n        s->max_ra = INT_MAX;\n    }\n    return 0;\n}', 'void av_buffer_unref(AVBufferRef **buf)\n{\n    AVBuffer *b;\n    if (!buf || !*buf)\n        return;\n    b = (*buf)->buffer;\n    av_freep(buf);\n    if (!avpriv_atomic_int_add_and_fetch(&b->refcount, -1)) {\n        b->free(b->opaque, b->data);\n        av_freep(&b);\n    }\n}', 'static int set_sps(HEVCContext *s, const HEVCSPS *sps)\n{\n    #define HWACCEL_MAX (CONFIG_HEVC_DXVA2_HWACCEL)\n    enum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmt = pix_fmts;\n    int ret;\n    export_stream_params(s->avctx, s, sps);\n    pic_arrays_free(s);\n    ret = pic_arrays_init(s, sps);\n    if (ret < 0)\n        goto fail;\n    if (sps->pix_fmt == AV_PIX_FMT_YUV420P || sps->pix_fmt == AV_PIX_FMT_YUVJ420P) {\n#if CONFIG_HEVC_DXVA2_HWACCEL\n        *fmt++ = AV_PIX_FMT_DXVA2_VLD;\n#endif\n    }\n    *fmt++ = sps->pix_fmt;\n    *fmt = AV_PIX_FMT_NONE;\n    ret = ff_get_format(s->avctx, pix_fmts);\n    if (ret < 0)\n        goto fail;\n    s->avctx->pix_fmt = ret;\n    ff_hevc_pred_init(&s->hpc,     sps->bit_depth);\n    ff_hevc_dsp_init (&s->hevcdsp, sps->bit_depth);\n    ff_videodsp_init (&s->vdsp,    sps->bit_depth);\n    if (sps->sao_enabled && !s->avctx->hwaccel) {\n        av_frame_unref(s->tmp_frame);\n        ret = ff_get_buffer(s->avctx, s->tmp_frame, AV_GET_BUFFER_FLAG_REF);\n        if (ret < 0)\n            goto fail;\n        s->frame = s->tmp_frame;\n    }\n    s->sps = sps;\n    s->vps = (HEVCVPS*) s->vps_list[s->sps->vps_id]->data;\n    return 0;\nfail:\n    pic_arrays_free(s);\n    s->sps = NULL;\n    return ret;\n}', 'static void export_stream_params(AVCodecContext *avctx,\n                                 const HEVCContext *s, const HEVCSPS *sps)\n{\n    const HEVCVPS *vps = (const HEVCVPS*)s->vps_list[sps->vps_id]->data;\n    unsigned int num = 0, den = 0;\n    avctx->pix_fmt             = sps->pix_fmt;\n    avctx->coded_width         = sps->width;\n    avctx->coded_height        = sps->height;\n    avctx->width               = sps->output_width;\n    avctx->height              = sps->output_height;\n    avctx->has_b_frames        = sps->temporal_layer[sps->max_sub_layers - 1].num_reorder_pics;\n    avctx->profile             = sps->ptl.general_ptl.profile_idc;\n    avctx->level               = sps->ptl.general_ptl.level_idc;\n    ff_set_sar(avctx, sps->vui.sar);\n    if (sps->vui.video_signal_type_present_flag)\n        avctx->color_range = sps->vui.video_full_range_flag ? AVCOL_RANGE_JPEG\n                                                            : AVCOL_RANGE_MPEG;\n    else\n        avctx->color_range = AVCOL_RANGE_MPEG;\n    if (sps->vui.colour_description_present_flag) {\n        avctx->color_primaries = sps->vui.colour_primaries;\n        avctx->color_trc       = sps->vui.transfer_characteristic;\n        avctx->colorspace      = sps->vui.matrix_coeffs;\n    } else {\n        avctx->color_primaries = AVCOL_PRI_UNSPECIFIED;\n        avctx->color_trc       = AVCOL_TRC_UNSPECIFIED;\n        avctx->colorspace      = AVCOL_SPC_UNSPECIFIED;\n    }\n    if (vps->vps_timing_info_present_flag) {\n        num = vps->vps_num_units_in_tick;\n        den = vps->vps_time_scale;\n    } else if (sps->vui.vui_timing_info_present_flag) {\n        num = sps->vui.vui_num_units_in_tick;\n        den = sps->vui.vui_time_scale;\n    }\n    if (num != 0 && den != 0)\n        av_reduce(&avctx->framerate.den, &avctx->framerate.num,\n                  num, den, 1 << 30);\n}']