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

libavformat/rtsp.c:684:17: Unknown value from: non-const function
682.         if (rtsp_st) {
683.             if (rtsp_st->dynamic_handler && rtsp_st->dynamic_protocol_context)
684.                 rtsp_st->dynamic_handler->free(
                     ^
685.                     rtsp_st->dynamic_protocol_context);
686.             for (j = 0; j < rtsp_st->nb_include_source_addrs; j++)

libavformat/rtsp.c:698:9: Call
696.     av_free(rt->rtsp_streams);
697.     if (rt->asf_ctx) {
698.         avformat_close_input(&rt->asf_ctx);
             ^
699.     }
700.     if (rt->ts && CONFIG_RTPDEC)

libavformat/utils.c:2542:1: Parameter `(*ps)->nb_programs`
  2540. }
  2541. 
  2542. void avformat_close_input(AVFormatContext **ps)
        ^
  2543. {
  2544.     AVFormatContext *s = *ps;

libavformat/utils.c:2558:5: Call
  2556.     }
  2557. 
  2558.     avformat_free_context(s);
            ^
  2559. 
  2560.     *ps = NULL;

libavformat/utils.c:2498:1: <LHS trace>
2496. }
2497. 
2498. void avformat_free_context(AVFormatContext *s)
      ^
2499. {
2500.     int i;

libavformat/utils.c:2498:1: Parameter `s->nb_programs`
    2496. }
    2497. 
    2498. void avformat_free_context(AVFormatContext *s)
          ^
    2499. {
    2500.     int i;

libavformat/utils.c:2525:9: Binary operation: ([0, +oo] - 1):unsigned32 by call to `avformat_close_input` 
    2523.         av_free(st);
    2524.     }
    2525.     for(i=s->nb_programs-1; i>=0; i--) {
                  ^
    2526.         av_dict_free(&s->programs[i]->metadata);
    2527.         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);
}
['void ff_rtsp_close_streams(AVFormatContext *s)\n{\n    RTSPState *rt = s->priv_data;\n    int i, j;\n    RTSPStream *rtsp_st;\n    ff_rtsp_undo_setup(s);\n    for (i = 0; i < rt->nb_rtsp_streams; i++) {\n        rtsp_st = rt->rtsp_streams[i];\n        if (rtsp_st) {\n            if (rtsp_st->dynamic_handler && rtsp_st->dynamic_protocol_context)\n                rtsp_st->dynamic_handler->free(\n                    rtsp_st->dynamic_protocol_context);\n            for (j = 0; j < rtsp_st->nb_include_source_addrs; j++)\n                av_free(rtsp_st->include_source_addrs[j]);\n            av_freep(&rtsp_st->include_source_addrs);\n            for (j = 0; j < rtsp_st->nb_exclude_source_addrs; j++)\n                av_free(rtsp_st->exclude_source_addrs[j]);\n            av_freep(&rtsp_st->exclude_source_addrs);\n            av_free(rtsp_st);\n        }\n    }\n    av_free(rt->rtsp_streams);\n    if (rt->asf_ctx) {\n        avformat_close_input(&rt->asf_ctx);\n    }\n    if (rt->ts && CONFIG_RTPDEC)\n        ff_mpegts_parse_close(rt->ts);\n    av_free(rt->p);\n    av_free(rt->recvbuf);\n}', 'void avformat_close_input(AVFormatContext **ps)\n{\n    AVFormatContext *s = *ps;\n    AVIOContext *pb = s->pb;\n    if ((s->iformat && s->iformat->flags & AVFMT_NOFILE) ||\n        (s->flags & AVFMT_FLAG_CUSTOM_IO))\n        pb = NULL;\n    flush_packet_queue(s);\n    if (s->iformat) {\n        if (s->iformat->read_close)\n            s->iformat->read_close(s);\n    }\n    avformat_free_context(s);\n    *ps = NULL;\n    avio_close(pb);\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}']