libavformat/rtpdec_asf.c:116: error: Null Dereference
  pointer `rt->asf_ctx` last assigned on line 111 could be null and is dereferenced at line 116, column 40.

libavformat/rtpdec_asf.c:95:1: start of procedure ff_wms_parse_sdp_a_line()
93. }
94. 
95. int ff_wms_parse_sdp_a_line(AVFormatContext *s, const char *p)
    ^
96. {
97.     int ret = 0;

libavformat/rtpdec_asf.c:97:5: 
95. int ff_wms_parse_sdp_a_line(AVFormatContext *s, const char *p)
96. {
97.     int ret = 0;
        ^
98.     if (av_strstart(p, "pgmpu:data:application/vnd.ms.wms-hdr.asfv1;base64,", &p)) {
99.         AVIOContext pb;

libavformat/rtpdec_asf.c:98:9: Taking true branch
 96. {
 97.     int ret = 0;
 98.     if (av_strstart(p, "pgmpu:data:application/vnd.ms.wms-hdr.asfv1;base64,", &p)) {
             ^
 99.         AVIOContext pb;
100.         RTSPState *rt = s->priv_data;

libavformat/rtpdec_asf.c:100:9: 
 98.     if (av_strstart(p, "pgmpu:data:application/vnd.ms.wms-hdr.asfv1;base64,", &p)) {
 99.         AVIOContext pb;
100.         RTSPState *rt = s->priv_data;
             ^
101.         int len = strlen(p) * 6 / 8;
102.         char *buf = av_mallocz(len);

libavformat/rtpdec_asf.c:101:9: 
 99.         AVIOContext pb;
100.         RTSPState *rt = s->priv_data;
101.         int len = strlen(p) * 6 / 8;
             ^
102.         char *buf = av_mallocz(len);
103.         av_base64_decode(buf, p, len);

libavformat/rtpdec_asf.c:102:9: 
100.         RTSPState *rt = s->priv_data;
101.         int len = strlen(p) * 6 / 8;
102.         char *buf = av_mallocz(len);
             ^
103.         av_base64_decode(buf, p, len);
104. 

libavutil/mem.c:156:1: start of procedure av_mallocz()
  154. }
  155. 
  156. void *av_mallocz(FF_INTERNAL_MEM_TYPE size)
       ^
  157. {
  158.     void *ptr = av_malloc(size);

libavutil/mem.c:158:5: 
  156. void *av_mallocz(FF_INTERNAL_MEM_TYPE size)
  157. {
  158.     void *ptr = av_malloc(size);
           ^
  159.     if (ptr)
  160.         memset(ptr, 0, size);

libavutil/mem.c:64:1: start of procedure av_malloc()
    62.    linker will do it automatically. */
    63. 
    64. void *av_malloc(FF_INTERNAL_MEM_TYPE size)
        ^
    65. {
    66.     void *ptr = NULL;

libavutil/mem.c:66:5: 
    64. void *av_malloc(FF_INTERNAL_MEM_TYPE size)
    65. {
    66.     void *ptr = NULL;
            ^
    67. #if CONFIG_MEMALIGN_HACK
    68.     long diff;

libavutil/mem.c:72:8: Taking true branch
    70. 
    71.     /* let's disallow possible ambiguous cases */
    72.     if(size > (INT_MAX-16) )
               ^
    73.         return NULL;
    74. 

libavutil/mem.c:73:9: 
    71.     /* let's disallow possible ambiguous cases */
    72.     if(size > (INT_MAX-16) )
    73.         return NULL;
                ^
    74. 
    75. #if CONFIG_MEMALIGN_HACK

libavutil/mem.c:117:1: return from a call to av_malloc
    115. #endif
    116.     return ptr;
    117. }
         ^
    118. 
    119. void *av_realloc(void *ptr, FF_INTERNAL_MEM_TYPE size)

libavutil/mem.c:159:9: Taking false branch
  157. {
  158.     void *ptr = av_malloc(size);
  159.     if (ptr)
               ^
  160.         memset(ptr, 0, size);
  161.     return ptr;

libavutil/mem.c:161:5: 
  159.     if (ptr)
  160.         memset(ptr, 0, size);
  161.     return ptr;
           ^
  162. }
  163. 

libavutil/mem.c:162:1: return from a call to av_mallocz
  160.         memset(ptr, 0, size);
  161.     return ptr;
  162. }
       ^
  163. 
  164. char *av_strdup(const char *s)

libavformat/rtpdec_asf.c:103:9: Skipping av_base64_decode(): empty list of specs
101.         int len = strlen(p) * 6 / 8;
102.         char *buf = av_mallocz(len);
103.         av_base64_decode(buf, p, len);
             ^
104. 
105.         if (rtp_asf_fix_header(buf, len) < 0)

libavformat/rtpdec_asf.c:105:13: Taking true branch
103.         av_base64_decode(buf, p, len);
104. 
105.         if (rtp_asf_fix_header(buf, len) < 0)
                 ^
106.             av_log(s, AV_LOG_ERROR,
107.                    "Failed to fix invalid RTSP-MS/ASF min_pktsize\n");

libavformat/rtpdec_asf.c:106:13: Skipping av_log(): empty list of specs
104. 
105.         if (rtp_asf_fix_header(buf, len) < 0)
106.             av_log(s, AV_LOG_ERROR,
                 ^
107.                    "Failed to fix invalid RTSP-MS/ASF min_pktsize\n");
108.         init_packetizer(&pb, buf, len);

libavformat/rtpdec_asf.c:108:9: 
106.             av_log(s, AV_LOG_ERROR,
107.                    "Failed to fix invalid RTSP-MS/ASF min_pktsize\n");
108.         init_packetizer(&pb, buf, len);
             ^
109.         if (rt->asf_ctx) {
110.             av_close_input_stream(rt->asf_ctx);

libavformat/rtpdec_asf.c:86:1: start of procedure init_packetizer()
  84. }
  85. 
  86. static void init_packetizer(AVIOContext *pb, uint8_t *buf, int len)
      ^
  87. {
  88.     ffio_init_context(pb, buf, len, 0, NULL, packetizer_read, NULL, NULL);

libavformat/rtpdec_asf.c:88:5: 
  86. static void init_packetizer(AVIOContext *pb, uint8_t *buf, int len)
  87. {
  88.     ffio_init_context(pb, buf, len, 0, NULL, packetizer_read, NULL, NULL);
          ^
  89. 
  90.     /* this "fills" the buffer with its current content */

libavformat/aviobuf.c:44:1: start of procedure ffio_init_context()
    42. #endif
    43. 
    44. int ffio_init_context(AVIOContext *s,
        ^
    45.                   unsigned char *buffer,
    46.                   int buffer_size,

libavformat/aviobuf.c:53:5: 
    51.                   int64_t (*seek)(void *opaque, int64_t offset, int whence))
    52. {
    53.     s->buffer = buffer;
            ^
    54.     s->buffer_size = buffer_size;
    55.     s->buf_ptr = buffer;

libavformat/aviobuf.c:54:5: 
    52. {
    53.     s->buffer = buffer;
    54.     s->buffer_size = buffer_size;
            ^
    55.     s->buf_ptr = buffer;
    56.     s->opaque = opaque;

libavformat/aviobuf.c:55:5: 
    53.     s->buffer = buffer;
    54.     s->buffer_size = buffer_size;
    55.     s->buf_ptr = buffer;
            ^
    56.     s->opaque = opaque;
    57.     url_resetbuf(s, write_flag ? URL_WRONLY : URL_RDONLY);

libavformat/aviobuf.c:56:5: 
    54.     s->buffer_size = buffer_size;
    55.     s->buf_ptr = buffer;
    56.     s->opaque = opaque;
            ^
    57.     url_resetbuf(s, write_flag ? URL_WRONLY : URL_RDONLY);
    58.     s->write_packet = write_packet;

libavformat/aviobuf.c:57:21: Condition is false
    55.     s->buf_ptr = buffer;
    56.     s->opaque = opaque;
    57.     url_resetbuf(s, write_flag ? URL_WRONLY : URL_RDONLY);
                            ^
    58.     s->write_packet = write_packet;
    59.     s->read_packet = read_packet;

libavformat/aviobuf.c:57:5: 
    55.     s->buf_ptr = buffer;
    56.     s->opaque = opaque;
    57.     url_resetbuf(s, write_flag ? URL_WRONLY : URL_RDONLY);
            ^
    58.     s->write_packet = write_packet;
    59.     s->read_packet = read_packet;

libavformat/aviobuf.c:877:1: start of procedure url_resetbuf()
      875. 
      876. #if FF_API_URL_RESETBUF
      877. int url_resetbuf(AVIOContext *s, int flags)
           ^
      878. #else
      879. static int url_resetbuf(AVIOContext *s, int flags)

libavformat/aviobuf.c:883:9: Taking false branch
      881. {
      882. #if FF_API_URL_RESETBUF
      883.     if (flags & URL_RDWR)
                   ^
      884.         return AVERROR(EINVAL);
      885. #else

libavformat/aviobuf.c:889:9: Taking true branch
      887. #endif
      888. 
      889.     if (flags & URL_WRONLY) {
                   ^
      890.         s->buf_end = s->buffer + s->buffer_size;
      891.         s->write_flag = 1;

libavformat/aviobuf.c:890:9: 
      888. 
      889.     if (flags & URL_WRONLY) {
      890.         s->buf_end = s->buffer + s->buffer_size;
                   ^
      891.         s->write_flag = 1;
      892.     } else {

libavformat/aviobuf.c:891:9: 
      889.     if (flags & URL_WRONLY) {
      890.         s->buf_end = s->buffer + s->buffer_size;
      891.         s->write_flag = 1;
                   ^
      892.     } else {
      893.         s->buf_end = s->buffer;

libavformat/aviobuf.c:896:5: 
      894.         s->write_flag = 0;
      895.     }
      896.     return 0;
               ^
      897. }
      898. 

libavformat/aviobuf.c:897:1: return from a call to url_resetbuf
      895.     }
      896.     return 0;
      897. }
           ^
      898. 
      899. int ffio_rewind_with_probe_data(AVIOContext *s, unsigned char *buf, int buf_size)

libavformat/aviobuf.c:58:5: 
    56.     s->opaque = opaque;
    57.     url_resetbuf(s, write_flag ? URL_WRONLY : URL_RDONLY);
    58.     s->write_packet = write_packet;
            ^
    59.     s->read_packet = read_packet;
    60.     s->seek = seek;

libavformat/aviobuf.c:59:5: 
    57.     url_resetbuf(s, write_flag ? URL_WRONLY : URL_RDONLY);
    58.     s->write_packet = write_packet;
    59.     s->read_packet = read_packet;
            ^
    60.     s->seek = seek;
    61.     s->pos = 0;

libavformat/aviobuf.c:60:5: 
    58.     s->write_packet = write_packet;
    59.     s->read_packet = read_packet;
    60.     s->seek = seek;
            ^
    61.     s->pos = 0;
    62.     s->must_flush = 0;

libavformat/aviobuf.c:61:5: 
    59.     s->read_packet = read_packet;
    60.     s->seek = seek;
    61.     s->pos = 0;
            ^
    62.     s->must_flush = 0;
    63.     s->eof_reached = 0;

libavformat/aviobuf.c:62:5: 
    60.     s->seek = seek;
    61.     s->pos = 0;
    62.     s->must_flush = 0;
            ^
    63.     s->eof_reached = 0;
    64.     s->error = 0;

libavformat/aviobuf.c:63:5: 
    61.     s->pos = 0;
    62.     s->must_flush = 0;
    63.     s->eof_reached = 0;
            ^
    64.     s->error = 0;
    65. #if FF_API_OLD_AVIO

libavformat/aviobuf.c:64:5: 
    62.     s->must_flush = 0;
    63.     s->eof_reached = 0;
    64.     s->error = 0;
            ^
    65. #if FF_API_OLD_AVIO
    66.     s->is_streamed = 0;

libavformat/aviobuf.c:66:5: 
    64.     s->error = 0;
    65. #if FF_API_OLD_AVIO
    66.     s->is_streamed = 0;
            ^
    67. #endif
    68.     s->seekable = AVIO_SEEKABLE_NORMAL;

libavformat/aviobuf.c:68:5: 
    66.     s->is_streamed = 0;
    67. #endif
    68.     s->seekable = AVIO_SEEKABLE_NORMAL;
            ^
    69.     s->max_packet_size = 0;
    70.     s->update_checksum= NULL;

libavformat/aviobuf.c:69:5: 
    67. #endif
    68.     s->seekable = AVIO_SEEKABLE_NORMAL;
    69.     s->max_packet_size = 0;
            ^
    70.     s->update_checksum= NULL;
    71.     if(!read_packet && !write_flag){

libavformat/aviobuf.c:70:5: 
    68.     s->seekable = AVIO_SEEKABLE_NORMAL;
    69.     s->max_packet_size = 0;
    70.     s->update_checksum= NULL;
            ^
    71.     if(!read_packet && !write_flag){
    72.         s->pos = buffer_size;

libavformat/aviobuf.c:71:9: Taking false branch
    69.     s->max_packet_size = 0;
    70.     s->update_checksum= NULL;
    71.     if(!read_packet && !write_flag){
                ^
    72.         s->pos = buffer_size;
    73.         s->buf_end = s->buffer + buffer_size;

libavformat/aviobuf.c:75:5: 
    73.         s->buf_end = s->buffer + buffer_size;
    74.     }
    75.     s->read_pause = NULL;
            ^
    76.     s->read_seek  = NULL;
    77.     return 0;

libavformat/aviobuf.c:76:5: 
    74.     }
    75.     s->read_pause = NULL;
    76.     s->read_seek  = NULL;
            ^
    77.     return 0;
    78. }

libavformat/aviobuf.c:77:5: 
    75.     s->read_pause = NULL;
    76.     s->read_seek  = NULL;
    77.     return 0;
            ^
    78. }
    79. 

libavformat/aviobuf.c:78:1: return from a call to ffio_init_context
    76.     s->read_seek  = NULL;
    77.     return 0;
    78. }
        ^
    79. 
    80. #if FF_API_OLD_AVIO

libavformat/rtpdec_asf.c:91:5: 
  89. 
  90.     /* this "fills" the buffer with its current content */
  91.     pb->pos     = len;
          ^
  92.     pb->buf_end = buf + len;
  93. }

libavformat/rtpdec_asf.c:92:5: 
  90.     /* this "fills" the buffer with its current content */
  91.     pb->pos     = len;
  92.     pb->buf_end = buf + len;
          ^
  93. }
  94. 

libavformat/rtpdec_asf.c:93:1: return from a call to init_packetizer
  91.     pb->pos     = len;
  92.     pb->buf_end = buf + len;
  93. }
      ^
  94. 
  95. int ff_wms_parse_sdp_a_line(AVFormatContext *s, const char *p)

libavformat/rtpdec_asf.c:109:13: Taking true branch
107.                    "Failed to fix invalid RTSP-MS/ASF min_pktsize\n");
108.         init_packetizer(&pb, buf, len);
109.         if (rt->asf_ctx) {
                 ^
110.             av_close_input_stream(rt->asf_ctx);
111.             rt->asf_ctx = NULL;

libavformat/rtpdec_asf.c:110:13: 
108.         init_packetizer(&pb, buf, len);
109.         if (rt->asf_ctx) {
110.             av_close_input_stream(rt->asf_ctx);
                 ^
111.             rt->asf_ctx = NULL;
112.         }

libavformat/utils.c:2583:1: start of procedure av_close_input_stream()
  2581. }
  2582. 
  2583. void av_close_input_stream(AVFormatContext *s)
        ^
  2584. {
  2585.     flush_packet_queue(s);

libavformat/utils.c:2585:5: Skipping flush_packet_queue(): empty list of specs
  2583. void av_close_input_stream(AVFormatContext *s)
  2584. {
  2585.     flush_packet_queue(s);
            ^
  2586.     if (s->iformat->read_close)
  2587.         s->iformat->read_close(s);

libavformat/utils.c:2586:9: Taking false branch
  2584. {
  2585.     flush_packet_queue(s);
  2586.     if (s->iformat->read_close)
                ^
  2587.         s->iformat->read_close(s);
  2588.     avformat_free_context(s);

libavformat/utils.c:2588:5: Skipping avformat_free_context(): empty list of specs
  2586.     if (s->iformat->read_close)
  2587.         s->iformat->read_close(s);
  2588.     avformat_free_context(s);
            ^
  2589. }
  2590. 

libavformat/utils.c:2589:1: return from a call to av_close_input_stream
  2587.         s->iformat->read_close(s);
  2588.     avformat_free_context(s);
  2589. }
        ^
  2590. 
  2591. void avformat_free_context(AVFormatContext *s)

libavformat/rtpdec_asf.c:111:13: 
109.         if (rt->asf_ctx) {
110.             av_close_input_stream(rt->asf_ctx);
111.             rt->asf_ctx = NULL;
                 ^
112.         }
113.         ret = av_open_input_stream(&rt->asf_ctx, &pb, "", &ff_asf_demuxer, NULL);

libavformat/rtpdec_asf.c:113:9: Skipping av_open_input_stream(): empty list of specs
111.             rt->asf_ctx = NULL;
112.         }
113.         ret = av_open_input_stream(&rt->asf_ctx, &pb, "", &ff_asf_demuxer, NULL);
             ^
114.         if (ret < 0)
115.             return ret;

libavformat/rtpdec_asf.c:114:13: Taking false branch
112.         }
113.         ret = av_open_input_stream(&rt->asf_ctx, &pb, "", &ff_asf_demuxer, NULL);
114.         if (ret < 0)
                 ^
115.             return ret;
116.         av_metadata_copy(&s->metadata, rt->asf_ctx->metadata, 0);

libavformat/rtpdec_asf.c:116:9: 
114.         if (ret < 0)
115.             return ret;
116.         av_metadata_copy(&s->metadata, rt->asf_ctx->metadata, 0);
             ^
117.         rt->asf_pb_pos = avio_tell(&pb);
118.         av_free(buf);

int ff_wms_parse_sdp_a_line(AVFormatContext *s, const char *p)
{
    int ret = 0;
    if (av_strstart(p, "pgmpu:data:application/vnd.ms.wms-hdr.asfv1;base64,", &p)) {
        AVIOContext pb;
        RTSPState *rt = s->priv_data;
        int len = strlen(p) * 6 / 8;
        char *buf = av_mallocz(len);
        av_base64_decode(buf, p, len);
        if (rtp_asf_fix_header(buf, len) < 0)
            av_log(s, AV_LOG_ERROR,
                   "Failed to fix invalid RTSP-MS/ASF min_pktsize\n");
        init_packetizer(&pb, buf, len);
        if (rt->asf_ctx) {
            av_close_input_stream(rt->asf_ctx);
            rt->asf_ctx = NULL;
        }
        ret = av_open_input_stream(&rt->asf_ctx, &pb, "", &ff_asf_demuxer, NULL);
        if (ret < 0)
            return ret;
        av_metadata_copy(&s->metadata, rt->asf_ctx->metadata, 0);
        rt->asf_pb_pos = avio_tell(&pb);
        av_free(buf);
        rt->asf_ctx->pb = NULL;
    }
    return ret;
}
['int ff_wms_parse_sdp_a_line(AVFormatContext *s, const char *p)\n{\n    int ret = 0;\n    if (av_strstart(p, "pgmpu:data:application/vnd.ms.wms-hdr.asfv1;base64,", &p)) {\n        AVIOContext pb;\n        RTSPState *rt = s->priv_data;\n        int len = strlen(p) * 6 / 8;\n        char *buf = av_mallocz(len);\n        av_base64_decode(buf, p, len);\n        if (rtp_asf_fix_header(buf, len) < 0)\n            av_log(s, AV_LOG_ERROR,\n                   "Failed to fix invalid RTSP-MS/ASF min_pktsize\\n");\n        init_packetizer(&pb, buf, len);\n        if (rt->asf_ctx) {\n            av_close_input_stream(rt->asf_ctx);\n            rt->asf_ctx = NULL;\n        }\n        ret = av_open_input_stream(&rt->asf_ctx, &pb, "", &ff_asf_demuxer, NULL);\n        if (ret < 0)\n            return ret;\n        av_metadata_copy(&s->metadata, rt->asf_ctx->metadata, 0);\n        rt->asf_pb_pos = avio_tell(&pb);\n        av_free(buf);\n        rt->asf_ctx->pb = NULL;\n    }\n    return ret;\n}', 'void *av_mallocz(FF_INTERNAL_MEM_TYPE size)\n{\n    void *ptr = av_malloc(size);\n    if (ptr)\n        memset(ptr, 0, size);\n    return ptr;\n}', 'void *av_malloc(FF_INTERNAL_MEM_TYPE size)\n{\n    void *ptr = NULL;\n#if CONFIG_MEMALIGN_HACK\n    long diff;\n#endif\n    if(size > (INT_MAX-16) )\n        return NULL;\n#if CONFIG_MEMALIGN_HACK\n    ptr = malloc(size+16);\n    if(!ptr)\n        return ptr;\n    diff= ((-(long)ptr - 1)&15) + 1;\n    ptr = (char*)ptr + diff;\n    ((char*)ptr)[-1]= diff;\n#elif HAVE_POSIX_MEMALIGN\n    if (posix_memalign(&ptr,16,size))\n        ptr = NULL;\n#elif HAVE_MEMALIGN\n    ptr = memalign(16,size);\n#else\n    ptr = malloc(size);\n#endif\n    return ptr;\n}', 'static void init_packetizer(AVIOContext *pb, uint8_t *buf, int len)\n{\n    ffio_init_context(pb, buf, len, 0, NULL, packetizer_read, NULL, NULL);\n    pb->pos     = len;\n    pb->buf_end = buf + len;\n}', 'int ffio_init_context(AVIOContext *s,\n                  unsigned char *buffer,\n                  int buffer_size,\n                  int write_flag,\n                  void *opaque,\n                  int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),\n                  int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),\n                  int64_t (*seek)(void *opaque, int64_t offset, int whence))\n{\n    s->buffer = buffer;\n    s->buffer_size = buffer_size;\n    s->buf_ptr = buffer;\n    s->opaque = opaque;\n    url_resetbuf(s, write_flag ? URL_WRONLY : URL_RDONLY);\n    s->write_packet = write_packet;\n    s->read_packet = read_packet;\n    s->seek = seek;\n    s->pos = 0;\n    s->must_flush = 0;\n    s->eof_reached = 0;\n    s->error = 0;\n#if FF_API_OLD_AVIO\n    s->is_streamed = 0;\n#endif\n    s->seekable = AVIO_SEEKABLE_NORMAL;\n    s->max_packet_size = 0;\n    s->update_checksum= NULL;\n    if(!read_packet && !write_flag){\n        s->pos = buffer_size;\n        s->buf_end = s->buffer + buffer_size;\n    }\n    s->read_pause = NULL;\n    s->read_seek  = NULL;\n    return 0;\n}', 'int url_resetbuf(AVIOContext *s, int flags)\n#else\nstatic int url_resetbuf(AVIOContext *s, int flags)\n#endif\n{\n#if FF_API_URL_RESETBUF\n    if (flags & URL_RDWR)\n        return AVERROR(EINVAL);\n#else\n    assert(flags == URL_WRONLY || flags == URL_RDONLY);\n#endif\n    if (flags & URL_WRONLY) {\n        s->buf_end = s->buffer + s->buffer_size;\n        s->write_flag = 1;\n    } else {\n        s->buf_end = s->buffer;\n        s->write_flag = 0;\n    }\n    return 0;\n}', 'void av_close_input_stream(AVFormatContext *s)\n{\n    flush_packet_queue(s);\n    if (s->iformat->read_close)\n        s->iformat->read_close(s);\n    avformat_free_context(s);\n}']