libavformat/utils.c:2698: error: Null Dereference
  pointer `pb` last assigned on line 2685 could be null and is dereferenced by call to `avio_close()` at line 2698, column 5.

libavformat/utils.c:2678:1: start of procedure avformat_close_input()
2676. }
2677. 
2678. void avformat_close_input(AVFormatContext **ps)
      ^
2679. {
2680.     AVFormatContext *s = *ps;

libavformat/utils.c:2680:5: 
2678. void avformat_close_input(AVFormatContext **ps)
2679. {
2680.     AVFormatContext *s = *ps;
          ^
2681.     AVIOContext *pb = s->pb;
2682. 

libavformat/utils.c:2681:5: 
2679. {
2680.     AVFormatContext *s = *ps;
2681.     AVIOContext *pb = s->pb;
          ^
2682. 
2683.     if ((s->iformat && s->iformat->flags & AVFMT_NOFILE) ||

libavformat/utils.c:2683:10: Taking true branch
2681.     AVIOContext *pb = s->pb;
2682. 
2683.     if ((s->iformat && s->iformat->flags & AVFMT_NOFILE) ||
               ^
2684.         (s->flags & AVFMT_FLAG_CUSTOM_IO))
2685.         pb = NULL;

libavformat/utils.c:2683:24: Taking false branch
2681.     AVIOContext *pb = s->pb;
2682. 
2683.     if ((s->iformat && s->iformat->flags & AVFMT_NOFILE) ||
                             ^
2684.         (s->flags & AVFMT_FLAG_CUSTOM_IO))
2685.         pb = NULL;

libavformat/utils.c:2684:10: Taking true branch
2682. 
2683.     if ((s->iformat && s->iformat->flags & AVFMT_NOFILE) ||
2684.         (s->flags & AVFMT_FLAG_CUSTOM_IO))
               ^
2685.         pb = NULL;
2686. 

libavformat/utils.c:2685:9: 
2683.     if ((s->iformat && s->iformat->flags & AVFMT_NOFILE) ||
2684.         (s->flags & AVFMT_FLAG_CUSTOM_IO))
2685.         pb = NULL;
              ^
2686. 
2687.     flush_packet_queue(s);

libavformat/utils.c:2687:5: Skipping flush_packet_queue(): empty list of specs
2685.         pb = NULL;
2686. 
2687.     flush_packet_queue(s);
          ^
2688. 
2689.     if (s->iformat) {

libavformat/utils.c:2689:9: Taking true branch
2687.     flush_packet_queue(s);
2688. 
2689.     if (s->iformat) {
              ^
2690.         if (s->iformat->read_close)
2691.             s->iformat->read_close(s);

libavformat/utils.c:2690:13: Taking true branch
2688. 
2689.     if (s->iformat) {
2690.         if (s->iformat->read_close)
                  ^
2691.             s->iformat->read_close(s);
2692.     }

libavformat/utils.c:2691:13: Skipping __function_pointer__(): unresolved function pointer
2689.     if (s->iformat) {
2690.         if (s->iformat->read_close)
2691.             s->iformat->read_close(s);
                  ^
2692.     }
2693. 

libavformat/utils.c:2694:5: Skipping avformat_free_context(): empty list of specs
2692.     }
2693. 
2694.     avformat_free_context(s);
          ^
2695. 
2696.     *ps = NULL;

libavformat/utils.c:2696:5: 
2694.     avformat_free_context(s);
2695. 
2696.     *ps = NULL;
          ^
2697. 
2698.     avio_close(pb);

libavformat/utils.c:2698:5: 
2696.     *ps = NULL;
2697. 
2698.     avio_close(pb);
          ^
2699. }
2700. 

libavformat/aviobuf.c:782:1: start of procedure avio_close()
  780. }
  781. 
  782. int avio_close(AVIOContext *s)
       ^
  783. {
  784.     URLContext *h;

libavformat/aviobuf.c:786:10: Taking false branch
  784.     URLContext *h;
  785. 
  786.     if (!s)
                ^
  787.         return 0;
  788. 

libavformat/aviobuf.c:789:5: 
  787.         return 0;
  788. 
  789.     avio_flush(s);
           ^
  790.     h = s->opaque;
  791.     av_freep(&s->buffer);

libavformat/aviobuf.c:180:1: start of procedure avio_flush()
    178. }
    179. 
    180. void avio_flush(AVIOContext *s)
         ^
    181. {
    182.     flush_buffer(s);

libavformat/aviobuf.c:182:5: 
    180. void avio_flush(AVIOContext *s)
    181. {
    182.     flush_buffer(s);
             ^
    183.     s->must_flush = 0;
    184. }

libavformat/aviobuf.c:124:1: start of procedure flush_buffer()
      122. }
      123. 
      124. static void flush_buffer(AVIOContext *s)
           ^
      125. {
      126.     if (s->buf_ptr > s->buffer) {

libavformat/aviobuf.c:126:9: 
      124. static void flush_buffer(AVIOContext *s)
      125. {
      126.     if (s->buf_ptr > s->buffer) {
                   ^
      127.         if (s->write_packet && !s->error) {
      128.             int ret = s->write_packet(s->opaque, s->buffer,

void avformat_close_input(AVFormatContext **ps)
{
    AVFormatContext *s = *ps;
    AVIOContext *pb = s->pb;
    if ((s->iformat && s->iformat->flags & AVFMT_NOFILE) ||
        (s->flags & AVFMT_FLAG_CUSTOM_IO))
        pb = NULL;
    flush_packet_queue(s);
    if (s->iformat) {
        if (s->iformat->read_close)
            s->iformat->read_close(s);
    }
    avformat_free_context(s);
    *ps = NULL;
    avio_close(pb);
}
['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}', '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 avio_flush(AVIOContext *s)\n{\n    flush_buffer(s);\n    s->must_flush = 0;\n}', 'static void flush_buffer(AVIOContext *s)\n{\n    if (s->buf_ptr > s->buffer) {\n        if (s->write_packet && !s->error) {\n            int ret = s->write_packet(s->opaque, s->buffer,\n                                      s->buf_ptr - s->buffer);\n            if (ret < 0) {\n                s->error = ret;\n            }\n        }\n        if (s->update_checksum) {\n            s->checksum     = s->update_checksum(s->checksum, s->checksum_ptr,\n                                                 s->buf_ptr - s->checksum_ptr);\n            s->checksum_ptr = s->buffer;\n        }\n        s->pos += s->buf_ptr - s->buffer;\n    }\n    s->buf_ptr = s->buffer;\n}']