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

libavformat/segment.c:352:20: Call
350. 
351.     if (!seg->write_header_trailer) {
352.         if ((ret = segment_end(oc, 0)) < 0)
                        ^
353.             goto fail;
354.         if ((ret = open_null_ctx(&oc->pb)) < 0)

libavformat/segment.c:165:9: Call
  163.     av_write_frame(oc, NULL); /* Flush any buffered data (fragmented mp4) */
  164.     if (write_trailer)
  165.         av_write_trailer(oc);
               ^
  166.     avio_close(oc->pb);
  167. 

libavformat/mux.c:634:9: Call
    632. fail:
    633.     for (i = 0; i < s->nb_streams; i++) {
    634.         av_freep(&s->streams[i]->priv_data);
                 ^
    635.         av_freep(&s->streams[i]->index_entries);
    636.     }

libavutil/mem.c:207:26: Assignment
      205. 
      206.     memcpy(&val, arg, sizeof(val));
      207.     memcpy(arg, &(void *){ NULL }, sizeof(val));
                                    ^
      208.     av_free(val);
      209. }

libavformat/segment.c:371:5: Call
369. 
370. fail:
371.     avio_close(seg->pb);
         ^
372.     avformat_free_context(oc);
373.     return ret;

libavformat/aviobuf.c:816:1: Parameter `s->opaque->is_connected`
  814. }
  815. 
  816. int avio_close(AVIOContext *s)
       ^
  817. {
  818.     URLContext *h;

libavformat/segment.c:372:5: Call
370. fail:
371.     avio_close(seg->pb);
372.     avformat_free_context(oc);
         ^
373.     return ret;
374. }

libavformat/utils.c:2433:1: <LHS trace>
2431. }
2432. 
2433. void avformat_free_context(AVFormatContext *s)
      ^
2434. {
2435.     int i, j;

libavformat/utils.c:2433:1: Parameter `s->nb_chapters`
  2431. }
  2432. 
  2433. void avformat_free_context(AVFormatContext *s)
        ^
  2434. {
  2435.     int i, j;

libavformat/utils.c:2476:12: Binary operation: ([-oo, 0] - 1):unsigned32 by call to `avformat_free_context` 
  2474.     av_freep(&s->programs);
  2475.     av_freep(&s->priv_data);
  2476.     while (s->nb_chapters--) {
                   ^
  2477.         av_dict_free(&s->chapters[s->nb_chapters]->metadata);
  2478.         av_free(s->chapters[s->nb_chapters]);

void avformat_free_context(AVFormatContext *s)
{
    int i, j;
    AVStream *st;
    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++) {
        st = s->streams[i];
        for (j = 0; j < st->nb_side_data; j++)
            av_freep(&st->side_data[j].data);
        av_freep(&st->side_data);
        st->nb_side_data = 0;
        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_freep(&s->internal);
    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 = 0;\n    if (!oc)\n        goto fail;\n    if (!seg->write_header_trailer) {\n        if ((ret = segment_end(oc, 0)) < 0)\n            goto fail;\n        if ((ret = open_null_ctx(&oc->pb)) < 0)\n            goto fail;\n        ret = av_write_trailer(oc);\n        close_null_ctx(oc->pb);\n    } else {\n        ret = segment_end(oc, 1);\n    }\n    if (ret < 0)\n        goto fail;\n    if (seg->list && seg->list_type == LIST_HLS) {\n        if ((ret = segment_hls_window(s, 1) < 0))\n            goto fail;\n    }\nfail:\n    avio_close(seg->pb);\n    avformat_free_context(oc);\n    return ret;\n}', 'static int segment_end(AVFormatContext *oc, int write_trailer)\n{\n    int ret = 0;\n    av_write_frame(oc, NULL);\n    if (write_trailer)\n        av_write_trailer(oc);\n    avio_close(oc->pb);\n    return ret;\n}', 'int av_write_trailer(AVFormatContext *s)\n{\n    int ret, i;\n    for (;; ) {\n        AVPacket pkt;\n        ret = interleave_packet(s, &pkt, NULL, 1);\n        if (ret < 0)\n            goto fail;\n        if (!ret)\n            break;\n        ret = write_packet(s, &pkt);\n        if (ret >= 0)\n            s->streams[pkt.stream_index]->nb_frames++;\n        av_free_packet(&pkt);\n        if (ret < 0)\n            goto fail;\n    }\n    if (s->oformat->write_trailer)\n        ret = s->oformat->write_trailer(s);\n    if (!(s->oformat->flags & AVFMT_NOFILE) && s->pb)\n        avio_flush(s->pb);\nfail:\n    for (i = 0; i < s->nb_streams; i++) {\n        av_freep(&s->streams[i]->priv_data);\n        av_freep(&s->streams[i]->index_entries);\n    }\n    if (s->oformat->priv_class)\n        av_opt_free(s->priv_data);\n    av_freep(&s->priv_data);\n    return ret;\n}', 'void av_freep(void *arg)\n{\n    void *val;\n    memcpy(&val, arg, sizeof(val));\n    memcpy(arg, &(void *){ NULL }, sizeof(val));\n    av_free(val);\n}', 'int avio_close(AVIOContext *s)\n{\n    URLContext *h;\n    if (!s)\n        return 0;\n    avio_flush(s);\n    h = s->opaque;\n    av_freep(&s->buffer);\n    av_free(s);\n    return ffurl_close(h);\n}', 'void avformat_free_context(AVFormatContext *s)\n{\n    int i, j;\n    AVStream *st;\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        st = s->streams[i];\n        for (j = 0; j < st->nb_side_data; j++)\n            av_freep(&st->side_data[j].data);\n        av_freep(&st->side_data);\n        st->nb_side_data = 0;\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_freep(&s->internal);\n    av_free(s);\n}']