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

libavformat/segment.c:130:9: Call
128. 
129.     if (write_header) {
130.         avformat_free_context(oc);
             ^
131.         c->avf = NULL;
132.         if ((err = segment_mux_init(s)) < 0)

libavformat/utils.c:2477:1: <LHS trace>
2475. }
2476. 
2477. void avformat_free_context(AVFormatContext *s)
      ^
2478. {
2479.     int i;

libavformat/utils.c:2477:1: Parameter `s->nb_programs`
  2475. }
  2476. 
  2477. void avformat_free_context(AVFormatContext *s)
        ^
  2478. {
  2479.     int i;

libavformat/utils.c:2491:10: Binary operation: ([0, +oo] - 1):unsigned32 by call to `avformat_free_context` 
  2489.         free_stream(&s->streams[i]);
  2490. 
  2491.     for (i = s->nb_programs - 1; i >= 0; i--) {
                 ^
  2492.         av_dict_free(&s->programs[i]->metadata);
  2493.         av_freep(&s->programs[i]->stream_index);

void avformat_free_context(AVFormatContext *s)
{
    int i;
    if (!s)
        return;
    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++)
        free_stream(&s->streams[i]);
    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_freep(&s->internal);
    av_free(s);
}
['static int segment_start(AVFormatContext *s, int write_header)\n{\n    SegmentContext *c = s->priv_data;\n    AVFormatContext *oc = c->avf;\n    int err = 0;\n    if (write_header) {\n        avformat_free_context(oc);\n        c->avf = NULL;\n        if ((err = segment_mux_init(s)) < 0)\n            return err;\n        oc = c->avf;\n    }\n    if (c->wrap)\n        c->number %= c->wrap;\n    if (av_get_frame_filename(oc->filename, sizeof(oc->filename),\n                              s->filename, c->number++) < 0)\n        return AVERROR(EINVAL);\n    if ((err = avio_open2(&oc->pb, oc->filename, AVIO_FLAG_WRITE,\n                          &s->interrupt_callback, NULL)) < 0)\n        return err;\n    if (oc->oformat->priv_class && oc->priv_data)\n        av_opt_set(oc->priv_data, "resend_headers", "1", 0);\n    if (write_header) {\n        if ((err = avformat_write_header(oc, NULL)) < 0)\n            return err;\n    }\n    return 0;\n}', 'void avformat_free_context(AVFormatContext *s)\n{\n    int i;\n    if (!s)\n        return;\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        free_stream(&s->streams[i]);\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_freep(&s->internal);\n    av_free(s);\n}']