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

libavformat/utils.c:2486:1: start of procedure avformat_close_input()
2484. }
2485. 
2486. void avformat_close_input(AVFormatContext **ps)
      ^
2487. {
2488.     AVFormatContext *s = *ps;

libavformat/utils.c:2488:5: 
2486. void avformat_close_input(AVFormatContext **ps)
2487. {
2488.     AVFormatContext *s = *ps;
          ^
2489.     AVIOContext *pb    = s->pb;
2490. 

libavformat/utils.c:2489:5: 
2487. {
2488.     AVFormatContext *s = *ps;
2489.     AVIOContext *pb    = s->pb;
          ^
2490. 
2491.     if ((s->iformat && s->iformat->flags & AVFMT_NOFILE) ||

libavformat/utils.c:2491:10: Taking true branch
2489.     AVIOContext *pb    = s->pb;
2490. 
2491.     if ((s->iformat && s->iformat->flags & AVFMT_NOFILE) ||
               ^
2492.         (s->flags & AVFMT_FLAG_CUSTOM_IO))
2493.         pb = NULL;

libavformat/utils.c:2491:24: Taking false branch
2489.     AVIOContext *pb    = s->pb;
2490. 
2491.     if ((s->iformat && s->iformat->flags & AVFMT_NOFILE) ||
                             ^
2492.         (s->flags & AVFMT_FLAG_CUSTOM_IO))
2493.         pb = NULL;

libavformat/utils.c:2492:10: Taking true branch
2490. 
2491.     if ((s->iformat && s->iformat->flags & AVFMT_NOFILE) ||
2492.         (s->flags & AVFMT_FLAG_CUSTOM_IO))
               ^
2493.         pb = NULL;
2494. 

libavformat/utils.c:2493:9: 
2491.     if ((s->iformat && s->iformat->flags & AVFMT_NOFILE) ||
2492.         (s->flags & AVFMT_FLAG_CUSTOM_IO))
2493.         pb = NULL;
              ^
2494. 
2495.     flush_packet_queue(s);

libavformat/utils.c:2495:5: 
2493.         pb = NULL;
2494. 
2495.     flush_packet_queue(s);
          ^
2496. 
2497.     if (s->iformat)

libavformat/utils.c:1025:1: start of procedure flush_packet_queue()
  1023. 
  1024. /* XXX: suppress the packet queue */
  1025. static void flush_packet_queue(AVFormatContext *s)
        ^
  1026. {
  1027.     free_packet_buffer(&s->parse_queue,       &s->parse_queue_end);

libavformat/utils.c:1027:5: Skipping free_packet_buffer(): empty list of specs
  1025. static void flush_packet_queue(AVFormatContext *s)
  1026. {
  1027.     free_packet_buffer(&s->parse_queue,       &s->parse_queue_end);
            ^
  1028.     free_packet_buffer(&s->packet_buffer,     &s->packet_buffer_end);
  1029.     free_packet_buffer(&s->raw_packet_buffer, &s->raw_packet_buffer_end);

libavformat/utils.c:1028:5: Skipping free_packet_buffer(): empty list of specs
  1026. {
  1027.     free_packet_buffer(&s->parse_queue,       &s->parse_queue_end);
  1028.     free_packet_buffer(&s->packet_buffer,     &s->packet_buffer_end);
            ^
  1029.     free_packet_buffer(&s->raw_packet_buffer, &s->raw_packet_buffer_end);
  1030. 

libavformat/utils.c:1029:5: Skipping free_packet_buffer(): empty list of specs
  1027.     free_packet_buffer(&s->parse_queue,       &s->parse_queue_end);
  1028.     free_packet_buffer(&s->packet_buffer,     &s->packet_buffer_end);
  1029.     free_packet_buffer(&s->raw_packet_buffer, &s->raw_packet_buffer_end);
            ^
  1030. 
  1031.     s->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE;

libavformat/utils.c:1031:5: 
  1029.     free_packet_buffer(&s->raw_packet_buffer, &s->raw_packet_buffer_end);
  1030. 
  1031.     s->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE;
            ^
  1032. }
  1033. 

libavformat/utils.c:1032:1: return from a call to flush_packet_queue
  1030. 
  1031.     s->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE;
  1032. }
        ^
  1033. 
  1034. /*******************************************************/

libavformat/utils.c:2497:9: Taking true branch
2495.     flush_packet_queue(s);
2496. 
2497.     if (s->iformat)
              ^
2498.         if (s->iformat->read_close)
2499.             s->iformat->read_close(s);

libavformat/utils.c:2498:13: Taking true branch
2496. 
2497.     if (s->iformat)
2498.         if (s->iformat->read_close)
                  ^
2499.             s->iformat->read_close(s);
2500. 

libavformat/utils.c:2499:13: Skipping __function_pointer__(): unresolved function pointer
2497.     if (s->iformat)
2498.         if (s->iformat->read_close)
2499.             s->iformat->read_close(s);
                  ^
2500. 
2501.     avformat_free_context(s);

libavformat/utils.c:2501:5: Skipping avformat_free_context(): empty list of specs
2499.             s->iformat->read_close(s);
2500. 
2501.     avformat_free_context(s);
          ^
2502. 
2503.     *ps = NULL;

libavformat/utils.c:2503:5: 
2501.     avformat_free_context(s);
2502. 
2503.     *ps = NULL;
          ^
2504. 
2505.     avio_close(pb);

libavformat/utils.c:2505:5: 
2503.     *ps = NULL;
2504. 
2505.     avio_close(pb);
          ^
2506. }
2507. 

libavformat/aviobuf.c:800:1: start of procedure avio_close()
  798. }
  799. 
  800. int avio_close(AVIOContext *s)
       ^
  801. {
  802.     URLContext *h;

libavformat/aviobuf.c:804:10: Taking false branch
  802.     URLContext *h;
  803. 
  804.     if (!s)
                ^
  805.         return 0;
  806. 

libavformat/aviobuf.c:807:5: 
  805.         return 0;
  806. 
  807.     avio_flush(s);
           ^
  808.     h = s->opaque;
  809.     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    avformat_free_context(s);\n    *ps = NULL;\n    avio_close(pb);\n}', 'static void flush_packet_queue(AVFormatContext *s)\n{\n    free_packet_buffer(&s->parse_queue,       &s->parse_queue_end);\n    free_packet_buffer(&s->packet_buffer,     &s->packet_buffer_end);\n    free_packet_buffer(&s->raw_packet_buffer, &s->raw_packet_buffer_end);\n    s->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE;\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}']