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

libavformat/utils.c:2509:1: start of procedure avformat_close_input()
2507. }
2508. 
2509. void avformat_close_input(AVFormatContext **ps)
      ^
2510. {
2511.     AVFormatContext *s = *ps;

libavformat/utils.c:2511:5: 
2509. void avformat_close_input(AVFormatContext **ps)
2510. {
2511.     AVFormatContext *s = *ps;
          ^
2512.     AVIOContext *pb    = s->pb;
2513. 

libavformat/utils.c:2512:5: 
2510. {
2511.     AVFormatContext *s = *ps;
2512.     AVIOContext *pb    = s->pb;
          ^
2513. 
2514.     if ((s->iformat && s->iformat->flags & AVFMT_NOFILE) ||

libavformat/utils.c:2514:10: Taking true branch
2512.     AVIOContext *pb    = s->pb;
2513. 
2514.     if ((s->iformat && s->iformat->flags & AVFMT_NOFILE) ||
               ^
2515.         (s->flags & AVFMT_FLAG_CUSTOM_IO))
2516.         pb = NULL;

libavformat/utils.c:2514:24: Taking false branch
2512.     AVIOContext *pb    = s->pb;
2513. 
2514.     if ((s->iformat && s->iformat->flags & AVFMT_NOFILE) ||
                             ^
2515.         (s->flags & AVFMT_FLAG_CUSTOM_IO))
2516.         pb = NULL;

libavformat/utils.c:2515:10: Taking true branch
2513. 
2514.     if ((s->iformat && s->iformat->flags & AVFMT_NOFILE) ||
2515.         (s->flags & AVFMT_FLAG_CUSTOM_IO))
               ^
2516.         pb = NULL;
2517. 

libavformat/utils.c:2516:9: 
2514.     if ((s->iformat && s->iformat->flags & AVFMT_NOFILE) ||
2515.         (s->flags & AVFMT_FLAG_CUSTOM_IO))
2516.         pb = NULL;
              ^
2517. 
2518.     flush_packet_queue(s);

libavformat/utils.c:2518:5: 
2516.         pb = NULL;
2517. 
2518.     flush_packet_queue(s);
          ^
2519. 
2520.     if (s->iformat)

libavformat/utils.c:1038:1: start of procedure flush_packet_queue()
  1036. 
  1037. /* XXX: suppress the packet queue */
  1038. static void flush_packet_queue(AVFormatContext *s)
        ^
  1039. {
  1040.     free_packet_buffer(&s->internal->parse_queue,       &s->internal->parse_queue_end);

libavformat/utils.c:1040:5: Skipping free_packet_buffer(): empty list of specs
  1038. static void flush_packet_queue(AVFormatContext *s)
  1039. {
  1040.     free_packet_buffer(&s->internal->parse_queue,       &s->internal->parse_queue_end);
            ^
  1041.     free_packet_buffer(&s->internal->packet_buffer,     &s->internal->packet_buffer_end);
  1042.     free_packet_buffer(&s->internal->raw_packet_buffer, &s->internal->raw_packet_buffer_end);

libavformat/utils.c:1041:5: Skipping free_packet_buffer(): empty list of specs
  1039. {
  1040.     free_packet_buffer(&s->internal->parse_queue,       &s->internal->parse_queue_end);
  1041.     free_packet_buffer(&s->internal->packet_buffer,     &s->internal->packet_buffer_end);
            ^
  1042.     free_packet_buffer(&s->internal->raw_packet_buffer, &s->internal->raw_packet_buffer_end);
  1043. 

libavformat/utils.c:1042:5: Skipping free_packet_buffer(): empty list of specs
  1040.     free_packet_buffer(&s->internal->parse_queue,       &s->internal->parse_queue_end);
  1041.     free_packet_buffer(&s->internal->packet_buffer,     &s->internal->packet_buffer_end);
  1042.     free_packet_buffer(&s->internal->raw_packet_buffer, &s->internal->raw_packet_buffer_end);
            ^
  1043. 
  1044.     s->internal->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE;

libavformat/utils.c:1044:5: 
  1042.     free_packet_buffer(&s->internal->raw_packet_buffer, &s->internal->raw_packet_buffer_end);
  1043. 
  1044.     s->internal->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE;
            ^
  1045. }
  1046. 

libavformat/utils.c:1045:1: return from a call to flush_packet_queue
  1043. 
  1044.     s->internal->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE;
  1045. }
        ^
  1046. 
  1047. /*******************************************************/

libavformat/utils.c:2520:9: Taking true branch
2518.     flush_packet_queue(s);
2519. 
2520.     if (s->iformat)
              ^
2521.         if (s->iformat->read_close)
2522.             s->iformat->read_close(s);

libavformat/utils.c:2521:13: Taking true branch
2519. 
2520.     if (s->iformat)
2521.         if (s->iformat->read_close)
                  ^
2522.             s->iformat->read_close(s);
2523. 

libavformat/utils.c:2522:13: Skipping __function_pointer__(): unresolved function pointer
2520.     if (s->iformat)
2521.         if (s->iformat->read_close)
2522.             s->iformat->read_close(s);
                  ^
2523. 
2524.     avformat_free_context(s);

libavformat/utils.c:2524:5: Skipping avformat_free_context(): empty list of specs
2522.             s->iformat->read_close(s);
2523. 
2524.     avformat_free_context(s);
          ^
2525. 
2526.     *ps = NULL;

libavformat/utils.c:2526:5: 
2524.     avformat_free_context(s);
2525. 
2526.     *ps = NULL;
          ^
2527. 
2528.     avio_close(pb);

libavformat/utils.c:2528:5: 
2526.     *ps = NULL;
2527. 
2528.     avio_close(pb);
          ^
2529. }
2530. 

libavformat/aviobuf.c:935:1: start of procedure avio_close()
  933. }
  934. 
  935. int avio_close(AVIOContext *s)
       ^
  936. {
  937.     AVIOInternal *internal;

libavformat/aviobuf.c:940:10: Taking false branch
  938.     URLContext *h;
  939. 
  940.     if (!s)
                ^
  941.         return 0;
  942. 

libavformat/aviobuf.c:943:5: 
  941.         return 0;
  942. 
  943.     avio_flush(s);
           ^
  944.     internal = s->opaque;
  945.     h        = internal->h;

libavformat/aviobuf.c:219:1: start of procedure avio_flush()
    217. }
    218. 
    219. void avio_flush(AVIOContext *s)
         ^
    220. {
    221.     flush_buffer(s);

libavformat/aviobuf.c:221:5: 
    219. void avio_flush(AVIOContext *s)
    220. {
    221.     flush_buffer(s);
             ^
    222.     s->must_flush = 0;
    223. }

libavformat/aviobuf.c:163:1: start of procedure flush_buffer()
      161. }
      162. 
      163. static void flush_buffer(AVIOContext *s)
           ^
      164. {
      165.     if (s->buf_ptr > s->buffer) {

libavformat/aviobuf.c:165:9: 
      163. static void flush_buffer(AVIOContext *s)
      164. {
      165.     if (s->buf_ptr > s->buffer) {
                   ^
      166.         if (s->write_packet && !s->error) {
      167.             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->internal->parse_queue,       &s->internal->parse_queue_end);\n    free_packet_buffer(&s->internal->packet_buffer,     &s->internal->packet_buffer_end);\n    free_packet_buffer(&s->internal->raw_packet_buffer, &s->internal->raw_packet_buffer_end);\n    s->internal->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE;\n}', 'int avio_close(AVIOContext *s)\n{\n    AVIOInternal *internal;\n    URLContext *h;\n    if (!s)\n        return 0;\n    avio_flush(s);\n    internal = s->opaque;\n    h        = internal->h;\n    av_opt_free(internal);\n    av_freep(&internal->protocols);\n    av_freep(&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}']