libavcodec/h264.c:1310: error: Integer Overflow L2
  ([0, max(1, `h->slice_context_count`)] - 1):unsigned32 by call to `ff_h264_execute_decode_slices`.

libavcodec/h264.c:1162:5: Assignment
1160. {
1161.     AVCodecContext *const avctx = h->avctx;
1162.     unsigned context_count = 0;
          ^
1163.     int nals_needed = 0; ///< number of NALs that need decoding before the next frame thread starts
1164.     int i, ret = 0;

libavcodec/h264.c:1310:19: Call
1308. 
1309.         if (context_count == h->max_contexts) {
1310.             ret = ff_h264_execute_decode_slices(h, context_count);
                        ^
1311.             if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
1312.                 goto end;

libavcodec/h264_slice.c:2226:1: <LHS trace>
2224.  * @param context_count number of contexts to execute
2225.  */
2226. int ff_h264_execute_decode_slices(H264Context *h, unsigned context_count)
      ^
2227. {
2228.     AVCodecContext *const avctx = h->avctx;

libavcodec/h264_slice.c:2226:1: Parameter `context_count`
  2224.  * @param context_count number of contexts to execute
  2225.  */
  2226. int ff_h264_execute_decode_slices(H264Context *h, unsigned context_count)
        ^
  2227. {
  2228.     AVCodecContext *const avctx = h->avctx;

libavcodec/h264_slice.c:2267:9: Binary operation: ([0, max(1, h->slice_context_count)] - 1):unsigned32 by call to `ff_h264_execute_decode_slices` 
  2265. 
  2266.         /* pull back stuff from slices to master context */
  2267.         sl                   = &h->slice_ctx[context_count - 1];
                ^
  2268.         h->mb_y              = sl->mb_y;
  2269.         for (i = 1; i < context_count; i++)

int ff_h264_execute_decode_slices(H264Context *h, unsigned context_count)
{
    AVCodecContext *const avctx = h->avctx;
    H264SliceContext *sl;
    int i, j;
    if (h->avctx->hwaccel)
        return 0;
    if (context_count == 1) {
        int ret;
        h->slice_ctx[0].next_slice_idx = h->mb_width * h->mb_height;
        ret = decode_slice(avctx, &h->slice_ctx[0]);
        h->mb_y = h->slice_ctx[0].mb_y;
        return ret;
    } else {
        for (i = 0; i < context_count; i++) {
            int next_slice_idx = h->mb_width * h->mb_height;
            int slice_idx;
            sl                 = &h->slice_ctx[i];
            sl->er.error_count = 0;
            slice_idx = sl->mb_y * h->mb_width + sl->mb_x;
            for (j = 0; j < context_count; j++) {
                H264SliceContext *sl2 = &h->slice_ctx[j];
                int        slice_idx2 = sl2->mb_y * h->mb_width + sl2->mb_x;
                if (i == j || slice_idx2 < slice_idx)
                    continue;
                next_slice_idx = FFMIN(next_slice_idx, slice_idx2);
            }
            sl->next_slice_idx = next_slice_idx;
        }
        avctx->execute(avctx, decode_slice, h->slice_ctx,
                       NULL, context_count, sizeof(h->slice_ctx[0]));
        sl                   = &h->slice_ctx[context_count - 1];
        h->mb_y              = sl->mb_y;
        for (i = 1; i < context_count; i++)
            h->slice_ctx[0].er.error_count += h->slice_ctx[i].er.error_count;
    }
    return 0;
}
['static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size,\n                            int parse_extradata)\n{\n    AVCodecContext *const avctx = h->avctx;\n    unsigned context_count = 0;\n    int nals_needed = 0;\n    int i, ret = 0;\n    h->max_contexts = h->slice_context_count;\n    if (!(avctx->flags2 & AV_CODEC_FLAG2_CHUNKS)) {\n        h->current_slice = 0;\n        if (!h->first_field)\n            h->cur_pic_ptr = NULL;\n        ff_h264_reset_sei(h);\n    }\n    ret = ff_h2645_packet_split(&h->pkt, buf, buf_size, avctx, h->is_avc,\n                                h->nal_length_size, avctx->codec_id);\n    if (ret < 0) {\n        av_log(avctx, AV_LOG_ERROR,\n               "Error splitting the input into NAL units.\\n");\n        return ret;\n    }\n    if (avctx->active_thread_type & FF_THREAD_FRAME)\n        nals_needed = get_last_needed_nal(h);\n    for (i = 0; i < h->pkt.nb_nals; i++) {\n        H2645NAL *nal = &h->pkt.nals[i];\n        H264SliceContext *sl = &h->slice_ctx[context_count];\n        int err;\n        if (avctx->skip_frame >= AVDISCARD_NONREF &&\n            nal->ref_idc == 0 && nal->type != NAL_SEI)\n            continue;\nagain:\n        if (parse_extradata && HAVE_THREADS &&\n            (h->avctx->active_thread_type & FF_THREAD_FRAME) &&\n            (nal->type != NAL_PPS && nal->type != NAL_SPS)) {\n            if (nal->type < NAL_AUD || nal->type > NAL_AUXILIARY_SLICE)\n                av_log(avctx, AV_LOG_INFO,\n                       "Ignoring NAL unit %d during extradata parsing\\n",\n                       nal->type);\n            nal->type = NAL_FF_IGNORE;\n        }\n        h->nal_ref_idc   = nal->ref_idc;\n        h->nal_unit_type = nal->type;\n        err = 0;\n        switch (nal->type) {\n        case NAL_IDR_SLICE:\n            if (nal->type != NAL_IDR_SLICE) {\n                av_log(h->avctx, AV_LOG_ERROR,\n                       "Invalid mix of idr and non-idr slices\\n");\n                ret = -1;\n                goto end;\n            }\n            idr(h);\n        case NAL_SLICE:\n            sl->gb = nal->gb;\n            if ((err = ff_h264_decode_slice_header(h, sl)))\n                break;\n            if (h->sei_recovery_frame_cnt >= 0 && h->recovery_frame < 0) {\n                h->recovery_frame = (h->frame_num + h->sei_recovery_frame_cnt) &\n                                    ((1 << h->sps.log2_max_frame_num) - 1);\n            }\n            h->cur_pic_ptr->f->key_frame |=\n                (nal->type == NAL_IDR_SLICE) || (h->sei_recovery_frame_cnt >= 0);\n            if (nal->type == NAL_IDR_SLICE || h->recovery_frame == h->frame_num) {\n                h->recovery_frame         = -1;\n                h->cur_pic_ptr->recovered = 1;\n            }\n            if (nal->type == NAL_IDR_SLICE)\n                h->frame_recovered |= FRAME_RECOVERED_IDR;\n            h->cur_pic_ptr->recovered |= !!(h->frame_recovered & FRAME_RECOVERED_IDR);\n            if (h->current_slice == 1) {\n                if (!(avctx->flags2 & AV_CODEC_FLAG2_CHUNKS))\n                    decode_postinit(h, i >= nals_needed);\n                if (h->avctx->hwaccel &&\n                    (ret = h->avctx->hwaccel->start_frame(h->avctx, NULL, 0)) < 0)\n                    return ret;\n            }\n            if (sl->redundant_pic_count == 0 &&\n                (avctx->skip_frame < AVDISCARD_NONREF || nal->ref_idc) &&\n                (avctx->skip_frame < AVDISCARD_BIDIR  ||\n                 sl->slice_type_nos != AV_PICTURE_TYPE_B) &&\n                (avctx->skip_frame < AVDISCARD_NONKEY ||\n                 h->cur_pic_ptr->f->key_frame) &&\n                avctx->skip_frame < AVDISCARD_ALL) {\n                if (avctx->hwaccel) {\n                    ret = avctx->hwaccel->decode_slice(avctx, nal->raw_data, nal->raw_size);\n                    if (ret < 0)\n                        return ret;\n                } else\n                    context_count++;\n            }\n            break;\n        case NAL_DPA:\n        case NAL_DPB:\n        case NAL_DPC:\n            avpriv_request_sample(avctx, "data partitioning");\n            ret = AVERROR(ENOSYS);\n            goto end;\n            break;\n        case NAL_SEI:\n            h->gb = nal->gb;\n            ret = ff_h264_decode_sei(h);\n            if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))\n                goto end;\n            break;\n        case NAL_SPS:\n            h->gb = nal->gb;\n            ret = ff_h264_decode_seq_parameter_set(h);\n            if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))\n                goto end;\n            break;\n        case NAL_PPS:\n            h->gb = nal->gb;\n            ret = ff_h264_decode_picture_parameter_set(h, nal->size_bits);\n            if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))\n                goto end;\n            break;\n        case NAL_AUD:\n        case NAL_END_SEQUENCE:\n        case NAL_END_STREAM:\n        case NAL_FILLER_DATA:\n        case NAL_SPS_EXT:\n        case NAL_AUXILIARY_SLICE:\n            break;\n        case NAL_FF_IGNORE:\n            break;\n        default:\n            av_log(avctx, AV_LOG_DEBUG, "Unknown NAL code: %d (%d bits)\\n",\n                   nal->type, nal->size_bits);\n        }\n        if (context_count == h->max_contexts) {\n            ret = ff_h264_execute_decode_slices(h, context_count);\n            if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))\n                goto end;\n            context_count = 0;\n        }\n        if (err < 0) {\n            av_log(h->avctx, AV_LOG_ERROR, "decode_slice_header error\\n");\n            sl->ref_count[0] = sl->ref_count[1] = sl->list_count = 0;\n        } else if (err == 1) {\n            sl               = &h->slice_ctx[0];\n            goto again;\n        }\n    }\n    if (context_count) {\n        ret = ff_h264_execute_decode_slices(h, context_count);\n        if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))\n            goto end;\n    }\n    ret = 0;\nend:\n    if (h->cur_pic_ptr && !h->droppable) {\n        ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX,\n                                  h->picture_structure == PICT_BOTTOM_FIELD);\n    }\n    return (ret < 0) ? ret : buf_size;\n}', 'int ff_h264_execute_decode_slices(H264Context *h, unsigned context_count)\n{\n    AVCodecContext *const avctx = h->avctx;\n    H264SliceContext *sl;\n    int i, j;\n    if (h->avctx->hwaccel)\n        return 0;\n    if (context_count == 1) {\n        int ret;\n        h->slice_ctx[0].next_slice_idx = h->mb_width * h->mb_height;\n        ret = decode_slice(avctx, &h->slice_ctx[0]);\n        h->mb_y = h->slice_ctx[0].mb_y;\n        return ret;\n    } else {\n        for (i = 0; i < context_count; i++) {\n            int next_slice_idx = h->mb_width * h->mb_height;\n            int slice_idx;\n            sl                 = &h->slice_ctx[i];\n            sl->er.error_count = 0;\n            slice_idx = sl->mb_y * h->mb_width + sl->mb_x;\n            for (j = 0; j < context_count; j++) {\n                H264SliceContext *sl2 = &h->slice_ctx[j];\n                int        slice_idx2 = sl2->mb_y * h->mb_width + sl2->mb_x;\n                if (i == j || slice_idx2 < slice_idx)\n                    continue;\n                next_slice_idx = FFMIN(next_slice_idx, slice_idx2);\n            }\n            sl->next_slice_idx = next_slice_idx;\n        }\n        avctx->execute(avctx, decode_slice, h->slice_ctx,\n                       NULL, context_count, sizeof(h->slice_ctx[0]));\n        sl                   = &h->slice_ctx[context_count - 1];\n        h->mb_y              = sl->mb_y;\n        for (i = 1; i < context_count; i++)\n            h->slice_ctx[0].er.error_count += h->slice_ctx[i].er.error_count;\n    }\n    return 0;\n}']