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

libavformat/assdec.c:145:1: start of procedure read_packet()
143. }
144. 
145. static int read_packet(AVFormatContext *s, AVPacket *pkt)
     ^
146. {
147.     ASSContext *ass = s->priv_data;

libavformat/assdec.c:147:5: 
145. static int read_packet(AVFormatContext *s, AVPacket *pkt)
146. {
147.     ASSContext *ass = s->priv_data;
         ^
148.     uint8_t *p, *end;
149. 

libavformat/assdec.c:150:8: Taking false branch
148.     uint8_t *p, *end;
149. 
150.     if(ass->event_index >= ass->event_count)
            ^
151.         return AVERROR(EIO);
152. 

libavformat/assdec.c:153:5: 
151.         return AVERROR(EIO);
152. 
153.     p= ass->event[ ass->event_index ];
         ^
154. 
155.     end= strchr(p, '\n');

libavformat/assdec.c:155:5: 
153.     p= ass->event[ ass->event_index ];
154. 
155.     end= strchr(p, '\n');
         ^
156.     av_new_packet(pkt, end ? end-p+1 : strlen(p));
157.     pkt->flags |= AV_PKT_FLAG_KEY;

libavformat/assdec.c:156:24: Condition is true
154. 
155.     end= strchr(p, '\n');
156.     av_new_packet(pkt, end ? end-p+1 : strlen(p));
                            ^
157.     pkt->flags |= AV_PKT_FLAG_KEY;
158.     pkt->pos= p - ass->event_buffer + s->streams[0]->codec->extradata_size;

libavformat/assdec.c:156:5: 
154. 
155.     end= strchr(p, '\n');
156.     av_new_packet(pkt, end ? end-p+1 : strlen(p));
         ^
157.     pkt->flags |= AV_PKT_FLAG_KEY;
158.     pkt->pos= p - ass->event_buffer + s->streams[0]->codec->extradata_size;

libavcodec/avpacket.c:56:1: start of procedure av_new_packet()
  54. }
  55. 
  56. int av_new_packet(AVPacket *pkt, int size)
      ^
  57. {
  58.     uint8_t *data = NULL;

libavcodec/avpacket.c:58:5: 
  56. int av_new_packet(AVPacket *pkt, int size)
  57. {
  58.     uint8_t *data = NULL;
          ^
  59.     if ((unsigned)size < (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE)
  60.         data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);

libavcodec/avpacket.c:59:9: Taking true branch
  57. {
  58.     uint8_t *data = NULL;
  59.     if ((unsigned)size < (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE)
              ^
  60.         data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
  61.     if (data) {

libavcodec/avpacket.c:60:9: 
  58.     uint8_t *data = NULL;
  59.     if ((unsigned)size < (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE)
  60.         data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
              ^
  61.     if (data) {
  62.         memset(data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);

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

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

libavutil/mem.c:74:9: Taking true branch
    72. 
    73.     /* let's disallow possible ambiguous cases */
    74.     if (size > (INT_MAX - 32) || !size)
                ^
    75.         return NULL;
    76. 

libavutil/mem.c:75:9: 
    73.     /* let's disallow possible ambiguous cases */
    74.     if (size > (INT_MAX - 32) || !size)
    75.         return NULL;
                ^
    76. 
    77. #if CONFIG_MEMALIGN_HACK

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

libavcodec/avpacket.c:61:9: Taking false branch
  59.     if ((unsigned)size < (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE)
  60.         data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
  61.     if (data) {
              ^
  62.         memset(data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
  63.     } else

libavcodec/avpacket.c:64:9: 
  62.         memset(data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
  63.     } else
  64.         size = 0;
              ^
  65. 
  66.     av_init_packet(pkt);

libavcodec/avpacket.c:66:5: 
  64.         size = 0;
  65. 
  66.     av_init_packet(pkt);
          ^
  67.     pkt->data     = data;
  68.     pkt->size     = size;

libavcodec/avpacket.c:42:1: start of procedure av_init_packet()
    40. }
    41. 
    42. void av_init_packet(AVPacket *pkt)
        ^
    43. {
    44.     pkt->pts                  = AV_NOPTS_VALUE;

libavcodec/avpacket.c:44:5: 
    42. void av_init_packet(AVPacket *pkt)
    43. {
    44.     pkt->pts                  = AV_NOPTS_VALUE;
            ^
    45.     pkt->dts                  = AV_NOPTS_VALUE;
    46.     pkt->pos                  = -1;

libavcodec/avpacket.c:45:5: 
    43. {
    44.     pkt->pts                  = AV_NOPTS_VALUE;
    45.     pkt->dts                  = AV_NOPTS_VALUE;
            ^
    46.     pkt->pos                  = -1;
    47.     pkt->duration             = 0;

libavcodec/avpacket.c:46:5: 
    44.     pkt->pts                  = AV_NOPTS_VALUE;
    45.     pkt->dts                  = AV_NOPTS_VALUE;
    46.     pkt->pos                  = -1;
            ^
    47.     pkt->duration             = 0;
    48.     pkt->convergence_duration = 0;

libavcodec/avpacket.c:47:5: 
    45.     pkt->dts                  = AV_NOPTS_VALUE;
    46.     pkt->pos                  = -1;
    47.     pkt->duration             = 0;
            ^
    48.     pkt->convergence_duration = 0;
    49.     pkt->flags                = 0;

libavcodec/avpacket.c:48:5: 
    46.     pkt->pos                  = -1;
    47.     pkt->duration             = 0;
    48.     pkt->convergence_duration = 0;
            ^
    49.     pkt->flags                = 0;
    50.     pkt->stream_index         = 0;

libavcodec/avpacket.c:49:5: 
    47.     pkt->duration             = 0;
    48.     pkt->convergence_duration = 0;
    49.     pkt->flags                = 0;
            ^
    50.     pkt->stream_index         = 0;
    51.     pkt->destruct             = NULL;

libavcodec/avpacket.c:50:5: 
    48.     pkt->convergence_duration = 0;
    49.     pkt->flags                = 0;
    50.     pkt->stream_index         = 0;
            ^
    51.     pkt->destruct             = NULL;
    52.     pkt->side_data            = NULL;

libavcodec/avpacket.c:51:5: 
    49.     pkt->flags                = 0;
    50.     pkt->stream_index         = 0;
    51.     pkt->destruct             = NULL;
            ^
    52.     pkt->side_data            = NULL;
    53.     pkt->side_data_elems      = 0;

libavcodec/avpacket.c:52:5: 
    50.     pkt->stream_index         = 0;
    51.     pkt->destruct             = NULL;
    52.     pkt->side_data            = NULL;
            ^
    53.     pkt->side_data_elems      = 0;
    54. }

libavcodec/avpacket.c:53:5: 
    51.     pkt->destruct             = NULL;
    52.     pkt->side_data            = NULL;
    53.     pkt->side_data_elems      = 0;
            ^
    54. }
    55. 

libavcodec/avpacket.c:54:1: return from a call to av_init_packet
    52.     pkt->side_data            = NULL;
    53.     pkt->side_data_elems      = 0;
    54. }
        ^
    55. 
    56. int av_new_packet(AVPacket *pkt, int size)

libavcodec/avpacket.c:67:5: 
  65. 
  66.     av_init_packet(pkt);
  67.     pkt->data     = data;
          ^
  68.     pkt->size     = size;
  69.     pkt->destruct = av_destruct_packet;

libavcodec/avpacket.c:68:5: 
  66.     av_init_packet(pkt);
  67.     pkt->data     = data;
  68.     pkt->size     = size;
          ^
  69.     pkt->destruct = av_destruct_packet;
  70.     if (!data)

libavcodec/avpacket.c:69:5: 
  67.     pkt->data     = data;
  68.     pkt->size     = size;
  69.     pkt->destruct = av_destruct_packet;
          ^
  70.     if (!data)
  71.         return AVERROR(ENOMEM);

libavcodec/avpacket.c:70:10: Taking true branch
  68.     pkt->size     = size;
  69.     pkt->destruct = av_destruct_packet;
  70.     if (!data)
               ^
  71.         return AVERROR(ENOMEM);
  72.     return 0;

libavcodec/avpacket.c:71:9: 
  69.     pkt->destruct = av_destruct_packet;
  70.     if (!data)
  71.         return AVERROR(ENOMEM);
              ^
  72.     return 0;
  73. }

libavcodec/avpacket.c:73:1: return from a call to av_new_packet
  71.         return AVERROR(ENOMEM);
  72.     return 0;
  73. }
      ^
  74. 
  75. void av_shrink_packet(AVPacket *pkt, int size)

libavformat/assdec.c:157:5: 
155.     end= strchr(p, '\n');
156.     av_new_packet(pkt, end ? end-p+1 : strlen(p));
157.     pkt->flags |= AV_PKT_FLAG_KEY;
         ^
158.     pkt->pos= p - ass->event_buffer + s->streams[0]->codec->extradata_size;
159.     pkt->pts= pkt->dts= get_pts(p);

libavformat/assdec.c:158:5: 
156.     av_new_packet(pkt, end ? end-p+1 : strlen(p));
157.     pkt->flags |= AV_PKT_FLAG_KEY;
158.     pkt->pos= p - ass->event_buffer + s->streams[0]->codec->extradata_size;
         ^
159.     pkt->pts= pkt->dts= get_pts(p);
160.     memcpy(pkt->data, p, pkt->size);

libavformat/assdec.c:159:5: 
157.     pkt->flags |= AV_PKT_FLAG_KEY;
158.     pkt->pos= p - ass->event_buffer + s->streams[0]->codec->extradata_size;
159.     pkt->pts= pkt->dts= get_pts(p);
         ^
160.     memcpy(pkt->data, p, pkt->size);
161. 

libavformat/assdec.c:56:1: start of procedure get_pts()
  54. }
  55. 
  56. static int64_t get_pts(const uint8_t *p)
      ^
  57. {
  58.     int hour, min, sec, hsec;

libavformat/assdec.c:60:8: Taking false branch
  58.     int hour, min, sec, hsec;
  59. 
  60.     if(sscanf(p, "%*[^,],%d:%d:%d%*c%d", &hour, &min, &sec, &hsec) != 4)
             ^
  61.         return AV_NOPTS_VALUE;
  62. 

libavformat/assdec.c:65:5: 
  63.     av_dlog(NULL, "%d %d %d %d [%s]\n", hour, min, sec, hsec, p);
  64. 
  65.     min+= 60*hour;
          ^
  66.     sec+= 60*min;
  67. 

libavformat/assdec.c:66:5: 
  64. 
  65.     min+= 60*hour;
  66.     sec+= 60*min;
          ^
  67. 
  68.     return sec*100+hsec;

libavformat/assdec.c:68:5: 
  66.     sec+= 60*min;
  67. 
  68.     return sec*100+hsec;
          ^
  69. }
  70. 

libavformat/assdec.c:69:1: return from a call to get_pts
  67. 
  68.     return sec*100+hsec;
  69. }
      ^
  70. 
  71. static int event_cmp(const void *_a, const void *_b)

libavformat/assdec.c:160:5: 
158.     pkt->pos= p - ass->event_buffer + s->streams[0]->codec->extradata_size;
159.     pkt->pts= pkt->dts= get_pts(p);
160.     memcpy(pkt->data, p, pkt->size);
         ^
161. 
162.     ass->event_index++;
