libavformat/segment.c:320: error: Integer Overflow L2
  ([0, +oo] - 1):unsigned32 by call to `avformat_free_context`.

libavformat/segment.c:314:11: Call
312.     }
313. 
314.     ret = ff_write_chained(oc, pkt->stream_index, pkt, s);
               ^
315. 
316. fail:

libavformat/mux.c:654:12: Call
  652.                                      src->streams[pkt->stream_index]->time_base,
  653.                                      dst->streams[dst_stream]->time_base);
  654.     return av_write_frame(dst, &local_pkt);
                  ^
  655. }

libavformat/mux.c:450:9: Assignment
    448. 
    449.     if (ret >= 0)
    450.         s->streams[pkt->stream_index]->nb_frames++;
                 ^
    451.     return ret;
    452. }

libavformat/segment.c:320:9: Call
318.         if (seg->list)
319.             avio_close(seg->pb);
320.         avformat_free_context(oc);
             ^
321.     }
322. 

libavformat/utils.c:2595:1: <LHS trace>
2593. }
2594. 
2595. void avformat_free_context(AVFormatContext *s)
      ^
2596. {
2597.     int i;

libavformat/utils.c:2595:1: Parameter `s->nb_programs`
  2593. }
  2594. 
  2595. void avformat_free_context(AVFormatContext *s)
        ^
  2596. {
  2597.     int i;

libavformat/utils.c:2622:10: Binary operation: ([0, +oo] - 1):unsigned32 by call to `avformat_free_context` 
  2620.         av_free(st);
  2621.     }
  2622.     for (i = s->nb_programs - 1; i >= 0; i--) {
                 ^
  2623.         av_dict_free(&s->programs[i]->metadata);
  2624.         av_freep(&s->programs[i]->stream_index);

void avformat_free_context(AVFormatContext *s)
{
    int i;
    AVStream *st;
    av_opt_free(s);
    if (s->iformat && s->iformat->priv_class && s->priv_data)
        av_opt_free(s->priv_data);
    for (i = 0; i < s->nb_streams; i++) {
        st = s->streams[i];
        if (st->parser) {
            av_parser_close(st->parser);
        }
        if (st->attached_pic.data)
            av_free_packet(&st->attached_pic);
        av_dict_free(&st->metadata);
        av_freep(&st->probe_data.buf);
        av_free(st->index_entries);
        av_free(st->codec->extradata);
        av_free(st->codec->subtitle_header);
        av_free(st->codec);
        av_free(st->priv_data);
        av_free(st->info);
        av_free(st);
    }
    for (i = s->nb_programs - 1; i >= 0; i--) {
        av_dict_free(&s->programs[i]->metadata);
        av_freep(&s->programs[i]->stream_index);
        av_freep(&s->programs[i]);
    }
    av_freep(&s->programs);
    av_freep(&s->priv_data);
    while (s->nb_chapters--) {
        av_dict_free(&s->chapters[s->nb_chapters]->metadata);
        av_free(s->chapters[s->nb_chapters]);
    }
    av_freep(&s->chapters);
    av_dict_free(&s->metadata);
    av_freep(&s->streams);
    av_free(s);
}
['static int seg_write_packet(AVFormatContext *s, AVPacket *pkt)\n{\n    SegmentContext *seg = s->priv_data;\n    AVFormatContext *oc = seg->avf;\n    AVStream *st = s->streams[pkt->stream_index];\n    int64_t end_pts = seg->recording_time * seg->number;\n    int ret, can_split = 1;\n    if (seg->has_video) {\n        can_split = st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&\n                    pkt->flags & AV_PKT_FLAG_KEY;\n    }\n    if (can_split && av_compare_ts(pkt->pts, st->time_base, end_pts,\n                                   AV_TIME_BASE_Q) >= 0) {\n        av_log(s, AV_LOG_DEBUG, "Next segment starts at %d %"PRId64"\\n",\n               pkt->stream_index, pkt->pts);\n        ret = segment_end(oc, seg->individual_header_trailer);\n        if (!ret)\n            ret = segment_start(s, seg->individual_header_trailer);\n        if (ret)\n            goto fail;\n        oc = seg->avf;\n        if (seg->list) {\n            if (seg->list_type == LIST_HLS) {\n                if ((ret = segment_hls_window(s, 0)) < 0)\n                    goto fail;\n            } else {\n                avio_printf(seg->pb, "%s\\n", oc->filename);\n                avio_flush(seg->pb);\n                if (seg->size && !(seg->number % seg->size)) {\n                    avio_closep(&seg->pb);\n                    if ((ret = avio_open2(&seg->pb, seg->list, AVIO_FLAG_WRITE,\n                                          &s->interrupt_callback, NULL)) < 0)\n                        goto fail;\n                }\n            }\n        }\n    }\n    ret = ff_write_chained(oc, pkt->stream_index, pkt, s);\nfail:\n    if (ret < 0) {\n        if (seg->list)\n            avio_close(seg->pb);\n        avformat_free_context(oc);\n    }\n    return ret;\n}', 'int ff_write_chained(AVFormatContext *dst, int dst_stream, AVPacket *pkt,\n                     AVFormatContext *src)\n{\n    AVPacket local_pkt;\n    local_pkt = *pkt;\n    local_pkt.stream_index = dst_stream;\n    if (pkt->pts != AV_NOPTS_VALUE)\n        local_pkt.pts = av_rescale_q(pkt->pts,\n                                     src->streams[pkt->stream_index]->time_base,\n                                     dst->streams[dst_stream]->time_base);\n    if (pkt->dts != AV_NOPTS_VALUE)\n        local_pkt.dts = av_rescale_q(pkt->dts,\n                                     src->streams[pkt->stream_index]->time_base,\n                                     dst->streams[dst_stream]->time_base);\n    return av_write_frame(dst, &local_pkt);\n}', 'int av_write_frame(AVFormatContext *s, AVPacket *pkt)\n{\n    int ret;\n    if (!pkt) {\n        if (s->oformat->flags & AVFMT_ALLOW_FLUSH)\n            return s->oformat->write_packet(s, pkt);\n        return 1;\n    }\n    ret = compute_pkt_fields2(s, s->streams[pkt->stream_index], pkt);\n    if (ret < 0 && !(s->oformat->flags & AVFMT_NOTIMESTAMPS))\n        return ret;\n    ret = write_packet(s, pkt);\n    if (ret >= 0)\n        s->streams[pkt->stream_index]->nb_frames++;\n    return ret;\n}', 'void avformat_free_context(AVFormatContext *s)\n{\n    int i;\n    AVStream *st;\n    av_opt_free(s);\n    if (s->iformat && s->iformat->priv_class && s->priv_data)\n        av_opt_free(s->priv_data);\n    for (i = 0; i < s->nb_streams; i++) {\n        st = s->streams[i];\n        if (st->parser) {\n            av_parser_close(st->parser);\n        }\n        if (st->attached_pic.data)\n            av_free_packet(&st->attached_pic);\n        av_dict_free(&st->metadata);\n        av_freep(&st->probe_data.buf);\n        av_free(st->index_entries);\n        av_free(st->codec->extradata);\n        av_free(st->codec->subtitle_header);\n        av_free(st->codec);\n        av_free(st->priv_data);\n        av_free(st->info);\n        av_free(st);\n    }\n    for (i = s->nb_programs - 1; i >= 0; i--) {\n        av_dict_free(&s->programs[i]->metadata);\n        av_freep(&s->programs[i]->stream_index);\n        av_freep(&s->programs[i]);\n    }\n    av_freep(&s->programs);\n    av_freep(&s->priv_data);\n    while (s->nb_chapters--) {\n        av_dict_free(&s->chapters[s->nb_chapters]->metadata);\n        av_free(s->chapters[s->nb_chapters]);\n    }\n    av_freep(&s->chapters);\n    av_dict_free(&s->metadata);\n    av_freep(&s->streams);\n    av_free(s);\n}']