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

libavformat/segment.c:241:5: Assignment
239.         avio_close(seg->pb);
240.     oc->streams = NULL;
241.     oc->nb_streams = 0;
         ^
242.     avformat_free_context(oc);
243.     return ret;

libavformat/segment.c:242:5: Call
240.     oc->streams = NULL;
241.     oc->nb_streams = 0;
242.     avformat_free_context(oc);
         ^
243.     return ret;
244. }

libavformat/utils.c:2650:1: <LHS trace>
2648. #endif
2649. 
2650. void avformat_free_context(AVFormatContext *s)
      ^
2651. {
2652.     int i;

libavformat/utils.c:2650:1: Parameter `s->nb_chapters`
  2648. #endif
  2649. 
  2650. void avformat_free_context(AVFormatContext *s)
        ^
  2651. {
  2652.     int i;

libavformat/utils.c:2682:11: Binary operation: ([-oo, 0] - 1):unsigned32 by call to `avformat_free_context` 
  2680.     av_freep(&s->programs);
  2681.     av_freep(&s->priv_data);
  2682.     while(s->nb_chapters--) {
                  ^
  2683.         av_dict_free(&s->chapters[s->nb_chapters]->metadata);
  2684.         av_free(s->chapters[s->nb_chapters]);

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);
            av_free_packet(&st->cur_pkt);
        }
        av_dict_free(&st->metadata);
        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_trailer(struct AVFormatContext *s)\n{\n    SegmentContext *seg = s->priv_data;\n    AVFormatContext *oc = seg->avf;\n    int ret = segment_end(oc);\n    if (seg->list)\n        avio_close(seg->pb);\n    oc->streams = NULL;\n    oc->nb_streams = 0;\n    avformat_free_context(oc);\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            av_free_packet(&st->cur_pkt);\n        }\n        av_dict_free(&st->metadata);\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}']