libavformat/rtpdec.c:496: error: Null Dereference
  pointer `pkt->data` last assigned on line 495 could be null and is dereferenced by call to `memcpy()` at line 496, column 13.

libavformat/rtpdec.c:402:1: start of procedure rtp_parse_packet()
400.  * (use buf as NULL to read the next). -1 if no packet (error or no more packet).
401.  */
402. int rtp_parse_packet(RTPDemuxContext *s, AVPacket *pkt,
     ^
403.                      const uint8_t *buf, int len)
404. {

libavformat/rtpdec.c:406:5: 
404. {
405.     unsigned int ssrc, h;
406.     int payload_type, seq, ret, flags = 0;
         ^
407.     AVStream *st;
408.     uint32_t timestamp;

libavformat/rtpdec.c:409:5: 
407.     AVStream *st;
408.     uint32_t timestamp;
409.     int rv= 0;
         ^
410. 
411.     if (!buf) {

libavformat/rtpdec.c:411:10: Taking false branch
409.     int rv= 0;
410. 
411.     if (!buf) {
              ^
412.         /* return the next packets, if any */
413.         if(s->st && s->parse_packet) {

libavformat/rtpdec.c:435:9: Taking false branch
433.     }
434. 
435.     if (len < 12)
             ^
436.         return -1;
437. 

libavformat/rtpdec.c:438:9: Taking false branch
436.         return -1;
437. 
438.     if ((buf[0] & 0xc0) != (RTP_VERSION << 6))
             ^
439.         return -1;
440.     if (buf[1] >= 200 && buf[1] <= 204) {

libavformat/rtpdec.c:440:9: Taking false branch
438.     if ((buf[0] & 0xc0) != (RTP_VERSION << 6))
439.         return -1;
440.     if (buf[1] >= 200 && buf[1] <= 204) {
             ^
441.         rtcp_parse_packet(s, buf, len);
442.         return -1;

libavformat/rtpdec.c:444:5: 
442.         return -1;
443.     }
444.     payload_type = buf[1] & 0x7f;
         ^
445.     if (buf[1] & 0x80)
446.         flags |= RTP_FLAG_MARKER;

libavformat/rtpdec.c:445:9: Taking true branch
443.     }
444.     payload_type = buf[1] & 0x7f;
445.     if (buf[1] & 0x80)
             ^
446.         flags |= RTP_FLAG_MARKER;
447.     seq  = AV_RB16(buf + 2);

libavformat/rtpdec.c:446:9: 
444.     payload_type = buf[1] & 0x7f;
445.     if (buf[1] & 0x80)
446.         flags |= RTP_FLAG_MARKER;
             ^
447.     seq  = AV_RB16(buf + 2);
448.     timestamp = AV_RB32(buf + 4);

libavformat/rtpdec.c:447:5: 
445.     if (buf[1] & 0x80)
446.         flags |= RTP_FLAG_MARKER;
447.     seq  = AV_RB16(buf + 2);
         ^
448.     timestamp = AV_RB32(buf + 4);
449.     ssrc = AV_RB32(buf + 8);

libavutil/bswap.h:46:1: start of procedure bswap_16()
  44. 
  45. #ifndef bswap_16
  46. static av_always_inline av_const uint16_t bswap_16(uint16_t x)
      ^
  47. {
  48.     x= (x>>8) | (x<<8);

libavutil/bswap.h:48:5: 
  46. static av_always_inline av_const uint16_t bswap_16(uint16_t x)
  47. {
  48.     x= (x>>8) | (x<<8);
          ^
  49.     return x;
  50. }

libavutil/bswap.h:49:5: 
  47. {
  48.     x= (x>>8) | (x<<8);
  49.     return x;
          ^
  50. }
  51. #endif

libavutil/bswap.h:50:1: return from a call to bswap_16
  48.     x= (x>>8) | (x<<8);
  49.     return x;
  50. }
      ^
  51. #endif
  52. 

libavformat/rtpdec.c:448:5: 
446.         flags |= RTP_FLAG_MARKER;
447.     seq  = AV_RB16(buf + 2);
448.     timestamp = AV_RB32(buf + 4);
         ^
449.     ssrc = AV_RB32(buf + 8);
450.     /* store the ssrc in the RTPDemuxContext */

libavutil/bswap.h:54:1: start of procedure bswap_32()
  52. 
  53. #ifndef bswap_32
  54. static av_always_inline av_const uint32_t bswap_32(uint32_t x)
      ^
  55. {
  56.     x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);

libavutil/bswap.h:56:5: 
  54. static av_always_inline av_const uint32_t bswap_32(uint32_t x)
  55. {
  56.     x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
          ^
  57.     x= (x>>16) | (x<<16);
  58.     return x;

libavutil/bswap.h:57:5: 
  55. {
  56.     x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
  57.     x= (x>>16) | (x<<16);
          ^
  58.     return x;
  59. }

libavutil/bswap.h:58:5: 
  56.     x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
  57.     x= (x>>16) | (x<<16);
  58.     return x;
          ^
  59. }
  60. #endif

libavutil/bswap.h:59:1: return from a call to bswap_32
  57.     x= (x>>16) | (x<<16);
  58.     return x;
  59. }
      ^
  60. #endif
  61. 

libavformat/rtpdec.c:449:5: 
447.     seq  = AV_RB16(buf + 2);
448.     timestamp = AV_RB32(buf + 4);
449.     ssrc = AV_RB32(buf + 8);
         ^
450.     /* store the ssrc in the RTPDemuxContext */
451.     s->ssrc = ssrc;

libavutil/bswap.h:54:1: start of procedure bswap_32()
  52. 
  53. #ifndef bswap_32
  54. static av_always_inline av_const uint32_t bswap_32(uint32_t x)
      ^
  55. {
  56.     x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);

libavutil/bswap.h:56:5: 
  54. static av_always_inline av_const uint32_t bswap_32(uint32_t x)
  55. {
  56.     x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
          ^
  57.     x= (x>>16) | (x<<16);
  58.     return x;

libavutil/bswap.h:57:5: 
  55. {
  56.     x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
  57.     x= (x>>16) | (x<<16);
          ^
  58.     return x;
  59. }

libavutil/bswap.h:58:5: 
  56.     x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
  57.     x= (x>>16) | (x<<16);
  58.     return x;
          ^
  59. }
  60. #endif

libavutil/bswap.h:59:1: return from a call to bswap_32
  57.     x= (x>>16) | (x<<16);
  58.     return x;
  59. }
      ^
  60. #endif
  61. 

libavformat/rtpdec.c:451:5: 
449.     ssrc = AV_RB32(buf + 8);
450.     /* store the ssrc in the RTPDemuxContext */
451.     s->ssrc = ssrc;
         ^
452. 
453.     /* NOTE: we can handle only one payload type */

libavformat/rtpdec.c:454:9: Taking false branch
452. 
453.     /* NOTE: we can handle only one payload type */
454.     if (s->payload_type != payload_type)
             ^
455.         return -1;
456. 

libavformat/rtpdec.c:457:5: 
455.         return -1;
456. 
457.     st = s->st;
         ^
458.     // only do something with this if all the rtp checks pass...
459.     if(!rtp_valid_packet_in_sequence(&s->statistics, seq))

libavformat/rtpdec.c:459:9: 
457.     st = s->st;
458.     // only do something with this if all the rtp checks pass...
459.     if(!rtp_valid_packet_in_sequence(&s->statistics, seq))
             ^
460.     {
461.         av_log(st?st->codec:NULL, AV_LOG_ERROR, "RTP: PT=%02x: bad cseq %04x expected=%04x\n",

libavformat/rtpdec.c:113:1: start of procedure rtp_valid_packet_in_sequence()
  111. * returns 1 if we should handle this packet.
  112. */
  113. static int rtp_valid_packet_in_sequence(RTPStatistics *s, uint16_t seq)
       ^
  114. {
  115.     uint16_t udelta= seq - s->max_seq;

libavformat/rtpdec.c:115:5: 
  113. static int rtp_valid_packet_in_sequence(RTPStatistics *s, uint16_t seq)
  114. {
  115.     uint16_t udelta= seq - s->max_seq;
           ^
  116.     const int MAX_DROPOUT= 3000;
  117.     const int MAX_MISORDER = 100;

libavformat/rtpdec.c:116:5: 
  114. {
  115.     uint16_t udelta= seq - s->max_seq;
  116.     const int MAX_DROPOUT= 3000;
           ^
  117.     const int MAX_MISORDER = 100;
  118.     const int MIN_SEQUENTIAL = 2;

libavformat/rtpdec.c:117:5: 
  115.     uint16_t udelta= seq - s->max_seq;
  116.     const int MAX_DROPOUT= 3000;
  117.     const int MAX_MISORDER = 100;
           ^
  118.     const int MIN_SEQUENTIAL = 2;
  119. 

libavformat/rtpdec.c:118:5: 
  116.     const int MAX_DROPOUT= 3000;
  117.     const int MAX_MISORDER = 100;
  118.     const int MIN_SEQUENTIAL = 2;
           ^
  119. 
  120.     /* source not valid until MIN_SEQUENTIAL packets with sequence seq. numbers have been received */

libavformat/rtpdec.c:121:8: Taking false branch
  119. 
  120.     /* source not valid until MIN_SEQUENTIAL packets with sequence seq. numbers have been received */
  121.     if(s->probation)
              ^
  122.     {
  123.         if(seq==s->max_seq + 1) {

libavformat/rtpdec.c:135:16: Taking false branch
  133.             s->max_seq = seq;
  134.         }
  135.     } else if (udelta < MAX_DROPOUT) {
                      ^
  136.         // in order, with permissible gap
  137.         if(seq < s->max_seq) {

libavformat/rtpdec.c:142:16: Taking false branch
  140.         }
  141.         s->max_seq= seq;
  142.     } else if (udelta <= RTP_SEQ_MOD - MAX_MISORDER) {
                      ^
  143.         // sequence made a large jump...
  144.         if(seq==s->bad_seq) {

libavformat/rtpdec.c:154:5: 
  152.         // duplicate or reordered packet...
  153.     }
  154.     s->received++;
           ^
  155.     return 1;
  156. }

libavformat/rtpdec.c:155:5: 
  153.     }
  154.     s->received++;
  155.     return 1;
           ^
  156. }
  157. 

libavformat/rtpdec.c:156:1: return from a call to rtp_valid_packet_in_sequence
  154.     s->received++;
  155.     return 1;
  156. }
       ^
  157. 
  158. #if 0

libavformat/rtpdec.c:459:9: Taking false branch
457.     st = s->st;
458.     // only do something with this if all the rtp checks pass...
459.     if(!rtp_valid_packet_in_sequence(&s->statistics, seq))
             ^
460.     {
461.         av_log(st?st->codec:NULL, AV_LOG_ERROR, "RTP: PT=%02x: bad cseq %04x expected=%04x\n",

libavformat/rtpdec.c:466:5: 
464.     }
465. 
466.     s->seq = seq;
         ^
467.     len -= 12;
468.     buf += 12;

libavformat/rtpdec.c:467:5: 
465. 
466.     s->seq = seq;
467.     len -= 12;
         ^
468.     buf += 12;
469. 

libavformat/rtpdec.c:468:5: 
466.     s->seq = seq;
467.     len -= 12;
468.     buf += 12;
         ^
469. 
470.     if (!st) {

libavformat/rtpdec.c:470:10: Taking false branch
468.     buf += 12;
469. 
470.     if (!st) {
              ^
471.         /* specific MPEG2TS demux support */
472.         ret = mpegts_parse_packet(s->ts, pkt, buf, len);

libavformat/rtpdec.c:482:16: Taking false branch
480.         }
481.         return 0;
482.     } else if (s->parse_packet) {
                    ^
483.         rv = s->parse_packet(s->ic, s->dynamic_protocol_context,
484.                              s->st, pkt, &timestamp, buf, len, flags);

libavformat/rtpdec.c:487:9: 
485.     } else {
486.         // at this point, the RTP header has been stripped;  This is ASSUMING that there is only 1 CSRC, which in't wise.
487.         switch(st->codec->codec_id) {
             ^
488.         case CODEC_ID_MP2:
489.             /* better than nothing: skip mpeg audio RTP header */

libavformat/rtpdec.c:488:9: Switch condition is true. Entering switch case
486.         // at this point, the RTP header has been stripped;  This is ASSUMING that there is only 1 CSRC, which in't wise.
487.         switch(st->codec->codec_id) {
488.         case CODEC_ID_MP2:
             ^
489.             /* better than nothing: skip mpeg audio RTP header */
490.             if (len <= 4)

libavformat/rtpdec.c:490:17: Taking false branch
488.         case CODEC_ID_MP2:
489.             /* better than nothing: skip mpeg audio RTP header */
490.             if (len <= 4)
                     ^
491.                 return -1;
492.             h = AV_RB32(buf);

libavformat/rtpdec.c:492:13: 
490.             if (len <= 4)
491.                 return -1;
492.             h = AV_RB32(buf);
                 ^
493.             len -= 4;
494.             buf += 4;

libavutil/bswap.h:54:1: start of procedure bswap_32()
  52. 
  53. #ifndef bswap_32
  54. static av_always_inline av_const uint32_t bswap_32(uint32_t x)
      ^
  55. {
  56.     x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);

libavutil/bswap.h:56:5: 
  54. static av_always_inline av_const uint32_t bswap_32(uint32_t x)
  55. {
  56.     x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
          ^
  57.     x= (x>>16) | (x<<16);
  58.     return x;

libavutil/bswap.h:57:5: 
  55. {
  56.     x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
  57.     x= (x>>16) | (x<<16);
          ^
  58.     return x;
  59. }

libavutil/bswap.h:58:5: 
  56.     x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
  57.     x= (x>>16) | (x<<16);
  58.     return x;
          ^
  59. }
  60. #endif

libavutil/bswap.h:59:1: return from a call to bswap_32
  57.     x= (x>>16) | (x<<16);
  58.     return x;
  59. }
      ^
  60. #endif
  61. 

libavformat/rtpdec.c:493:13: 
491.                 return -1;
492.             h = AV_RB32(buf);
493.             len -= 4;
                 ^
494.             buf += 4;
495.             av_new_packet(pkt, len);

libavformat/rtpdec.c:494:13: 
492.             h = AV_RB32(buf);
493.             len -= 4;
494.             buf += 4;
                 ^
495.             av_new_packet(pkt, len);
496.             memcpy(pkt->data, buf, len);

libavformat/rtpdec.c:495:13: 
493.             len -= 4;
494.             buf += 4;
495.             av_new_packet(pkt, len);
                 ^
496.             memcpy(pkt->data, buf, len);
497.             break;

libavcodec/avpacket.c:48:1: start of procedure av_new_packet()
  46. }
  47. 
  48. int av_new_packet(AVPacket *pkt, int size)
      ^
  49. {
  50.     uint8_t *data= NULL;

libavcodec/avpacket.c:50:5: 
  48. int av_new_packet(AVPacket *pkt, int size)
  49. {
  50.     uint8_t *data= NULL;
          ^
  51.     if((unsigned)size < (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE)
  52.         data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);

libavcodec/avpacket.c:51:8: Taking true branch
  49. {
  50.     uint8_t *data= NULL;
  51.     if((unsigned)size < (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE)
             ^
  52.         data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
  53.     if (data){

libavcodec/avpacket.c:52:9: 
  50.     uint8_t *data= NULL;
  51.     if((unsigned)size < (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE)
  52.         data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
              ^
  53.     if (data){
  54.         memset(data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);

libavutil/mem.c:47:1: start of procedure av_malloc()
    45.    linker will do it automatically. */
    46. 
    47. void *av_malloc(unsigned int size)
        ^
    48. {
    49.     void *ptr = NULL;

libavutil/mem.c:49:5: 
    47. void *av_malloc(unsigned int size)
    48. {
    49.     void *ptr = NULL;
            ^
    50. #if CONFIG_MEMALIGN_HACK
    51.     long diff;

libavutil/mem.c:55:8: Taking true branch
    53. 
    54.     /* let's disallow possible ambiguous cases */
    55.     if(size > (INT_MAX-16) )
               ^
    56.         return NULL;
    57. 

libavutil/mem.c:56:9: 
    54.     /* let's disallow possible ambiguous cases */
    55.     if(size > (INT_MAX-16) )
    56.         return NULL;
                ^
    57. 
    58. #if CONFIG_MEMALIGN_HACK

libavutil/mem.c:100:1: return from a call to av_malloc
     98. #endif
     99.     return ptr;
    100. }
         ^
    101. 
    102. void *av_realloc(void *ptr, unsigned int size)

libavcodec/avpacket.c:53:9: Taking false branch
  51.     if((unsigned)size < (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE)
  52.         data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
  53.     if (data){
              ^
  54.         memset(data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
  55.     }else

libavcodec/avpacket.c:56:9: 
  54.         memset(data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
  55.     }else
  56.         size=0;
              ^
  57. 
  58.     av_init_packet(pkt);

libavcodec/avpacket.c:58:5: 
  56.         size=0;
  57. 
  58.     av_init_packet(pkt);
          ^
  59.     pkt->data = data;
  60.     pkt->size = size;

libavcodec/avpacket.c:36:1: start of procedure av_init_packet()
    34. }
    35. 
    36. void av_init_packet(AVPacket *pkt)
        ^
    37. {
    38.     pkt->pts   = AV_NOPTS_VALUE;

libavcodec/avpacket.c:38:5: 
    36. void av_init_packet(AVPacket *pkt)
    37. {
    38.     pkt->pts   = AV_NOPTS_VALUE;
            ^
    39.     pkt->dts   = AV_NOPTS_VALUE;
    40.     pkt->pos   = -1;

libavcodec/avpacket.c:39:5: 
    37. {
    38.     pkt->pts   = AV_NOPTS_VALUE;
    39.     pkt->dts   = AV_NOPTS_VALUE;
            ^
    40.     pkt->pos   = -1;
    41.     pkt->duration = 0;

libavcodec/avpacket.c:40:5: 
    38.     pkt->pts   = AV_NOPTS_VALUE;
    39.     pkt->dts   = AV_NOPTS_VALUE;
    40.     pkt->pos   = -1;
            ^
    41.     pkt->duration = 0;
    42.     pkt->convergence_duration = 0;

libavcodec/avpacket.c:41:5: 
    39.     pkt->dts   = AV_NOPTS_VALUE;
    40.     pkt->pos   = -1;
    41.     pkt->duration = 0;
            ^
    42.     pkt->convergence_duration = 0;
    43.     pkt->flags = 0;

libavcodec/avpacket.c:42:5: 
    40.     pkt->pos   = -1;
    41.     pkt->duration = 0;
    42.     pkt->convergence_duration = 0;
            ^
    43.     pkt->flags = 0;
    44.     pkt->stream_index = 0;

libavcodec/avpacket.c:43:5: 
    41.     pkt->duration = 0;
    42.     pkt->convergence_duration = 0;
    43.     pkt->flags = 0;
            ^
    44.     pkt->stream_index = 0;
    45.     pkt->destruct= NULL;

libavcodec/avpacket.c:44:5: 
    42.     pkt->convergence_duration = 0;
    43.     pkt->flags = 0;
    44.     pkt->stream_index = 0;
            ^
    45.     pkt->destruct= NULL;
    46. }

libavcodec/avpacket.c:45:5: 
    43.     pkt->flags = 0;
    44.     pkt->stream_index = 0;
    45.     pkt->destruct= NULL;
            ^
    46. }
    47. 

libavcodec/avpacket.c:46:1: return from a call to av_init_packet
    44.     pkt->stream_index = 0;
    45.     pkt->destruct= NULL;
    46. }
        ^
    47. 
    48. int av_new_packet(AVPacket *pkt, int size)

libavcodec/avpacket.c:59:5: 
  57. 
  58.     av_init_packet(pkt);
  59.     pkt->data = data;
          ^
  60.     pkt->size = size;
  61.     pkt->destruct = av_destruct_packet;

libavcodec/avpacket.c:60:5: 
  58.     av_init_packet(pkt);
  59.     pkt->data = data;
  60.     pkt->size = size;
          ^
  61.     pkt->destruct = av_destruct_packet;
  62.     if(!data)

libavcodec/avpacket.c:61:5: 
  59.     pkt->data = data;
  60.     pkt->size = size;
  61.     pkt->destruct = av_destruct_packet;
          ^
  62.     if(!data)
  63.         return AVERROR(ENOMEM);

libavcodec/avpacket.c:62:9: Taking true branch
  60.     pkt->size = size;
  61.     pkt->destruct = av_destruct_packet;
  62.     if(!data)
              ^
  63.         return AVERROR(ENOMEM);
  64.     return 0;

libavcodec/avpacket.c:63:9: 
  61.     pkt->destruct = av_destruct_packet;
  62.     if(!data)
  63.         return AVERROR(ENOMEM);
              ^
  64.     return 0;
  65. }

libavcodec/avpacket.c:65:1: return from a call to av_new_packet
  63.         return AVERROR(ENOMEM);
  64.     return 0;
  65. }
      ^
  66. 
  67. void av_shrink_packet(AVPacket *pkt, int size)

libavformat/rtpdec.c:496:13: 
494.             buf += 4;
495.             av_new_packet(pkt, len);
496.             memcpy(pkt->data, buf, len);
                 ^
497.             break;
498.         case CODEC_ID_MPEG1VIDEO:
