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

libavformat/assdec.c:156:1: start of procedure read_packet()
154. }
155. 
156. static int read_packet(AVFormatContext *s, AVPacket *pkt)
     ^
157. {
158.     ASSContext *ass = s->priv_data;

libavformat/assdec.c:158:5: 
156. static int read_packet(AVFormatContext *s, AVPacket *pkt)
157. {
158.     ASSContext *ass = s->priv_data;
         ^
159.     uint8_t *p, *end;
160. 

libavformat/assdec.c:161:8: Taking false branch
159.     uint8_t *p, *end;
160. 
161.     if(ass->event_index >= ass->event_count)
            ^
162.         return AVERROR(EIO);
163. 

libavformat/assdec.c:164:5: 
162.         return AVERROR(EIO);
163. 
164.     p= ass->event[ ass->event_index ];
         ^
165. 
166.     end= strchr(p, '\n');

libavformat/assdec.c:166:5: 
164.     p= ass->event[ ass->event_index ];
165. 
166.     end= strchr(p, '\n');
         ^
167.     av_new_packet(pkt, end ? end-p+1 : strlen(p));
168.     pkt->flags |= AV_PKT_FLAG_KEY;

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

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

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:64:1: start of procedure av_malloc()
    62.    linker will do it automatically. */
    63. 
    64. void *av_malloc(unsigned int size)
        ^
    65. {
    66.     void *ptr = NULL;

libavutil/mem.c:66:5: 
    64. void *av_malloc(unsigned int 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, 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/assdec.c:168:5: 
166.     end= strchr(p, '\n');
167.     av_new_packet(pkt, end ? end-p+1 : strlen(p));
168.     pkt->flags |= AV_PKT_FLAG_KEY;
         ^
169.     pkt->pos= p - ass->event_buffer + s->streams[0]->codec->extradata_size;
170.     pkt->pts= pkt->dts= get_pts(p);

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

libavformat/assdec.c:170:5: 
168.     pkt->flags |= AV_PKT_FLAG_KEY;
169.     pkt->pos= p - ass->event_buffer + s->streams[0]->codec->extradata_size;
170.     pkt->pts= pkt->dts= get_pts(p);
         ^
171.     memcpy(pkt->data, p, pkt->size);
172. 

libavformat/assdec.c:68:1: start of procedure get_pts()
  66. }
  67. 
  68. static int64_t get_pts(const uint8_t *p)
      ^
  69. {
  70.     int hour, min, sec, hsec;

libavformat/assdec.c:72:8: Taking false branch
  70.     int hour, min, sec, hsec;
  71. 
  72.     if(sscanf(p, "%*[^,],%d:%d:%d%*c%d", &hour, &min, &sec, &hsec) != 4)
             ^
  73.         return AV_NOPTS_VALUE;
  74. 

libavformat/assdec.c:77:5: 
  75. //    av_log(NULL, AV_LOG_ERROR, "%d %d %d %d %d [%s]\n", i, hour, min, sec, hsec, p);
  76. 
  77.     min+= 60*hour;
          ^
  78.     sec+= 60*min;
  79. 

libavformat/assdec.c:78:5: 
  76. 
  77.     min+= 60*hour;
  78.     sec+= 60*min;
          ^
  79. 
  80.     return sec*100+hsec;

libavformat/assdec.c:80:5: 
  78.     sec+= 60*min;
  79. 
  80.     return sec*100+hsec;
          ^
  81. }
  82. 

libavformat/assdec.c:81:1: return from a call to get_pts
  79. 
  80.     return sec*100+hsec;
  81. }
      ^
  82. 
  83. static int event_cmp(uint8_t **a, uint8_t **b)

libavformat/assdec.c:171:5: 
169.     pkt->pos= p - ass->event_buffer + s->streams[0]->codec->extradata_size;
170.     pkt->pts= pkt->dts= get_pts(p);
171.     memcpy(pkt->data, p, pkt->size);
         ^
172. 
173.     ass->event_index++;

static int read_packet(AVFormatContext *s, AVPacket *pkt)
{
    ASSContext *ass = s->priv_data;
    uint8_t *p, *end;
    if(ass->event_index >= ass->event_count)
        return AVERROR(EIO);
    p= ass->event[ ass->event_index ];
    end= strchr(p, '\n');
    av_new_packet(pkt, end ? end-p+1 : strlen(p));
    pkt->flags |= AV_PKT_FLAG_KEY;
    pkt->pos= p - ass->event_buffer + s->streams[0]->codec->extradata_size;
    pkt->pts= pkt->dts= get_pts(p);
    memcpy(pkt->data, p, pkt->size);
    ass->event_index++;
    return 0;
}
["static int read_packet(AVFormatContext *s, AVPacket *pkt)\n{\n    ASSContext *ass = s->priv_data;\n    uint8_t *p, *end;\n    if(ass->event_index >= ass->event_count)\n        return AVERROR(EIO);\n    p= ass->event[ ass->event_index ];\n    end= strchr(p, '\\n');\n    av_new_packet(pkt, end ? end-p+1 : strlen(p));\n    pkt->flags |= AV_PKT_FLAG_KEY;\n    pkt->pos= p - ass->event_buffer + s->streams[0]->codec->extradata_size;\n    pkt->pts= pkt->dts= get_pts(p);\n    memcpy(pkt->data, p, pkt->size);\n    ass->event_index++;\n    return 0;\n}", 'int av_new_packet(AVPacket *pkt, int size)\n{\n    uint8_t *data= NULL;\n    if((unsigned)size < (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE)\n        data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);\n    if (data){\n        memset(data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);\n    }else\n        size=0;\n    av_init_packet(pkt);\n    pkt->data = data;\n    pkt->size = size;\n    pkt->destruct = av_destruct_packet;\n    if(!data)\n        return AVERROR(ENOMEM);\n    return 0;\n}', 'void *av_malloc(unsigned int 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}', 'void av_init_packet(AVPacket *pkt)\n{\n    pkt->pts   = AV_NOPTS_VALUE;\n    pkt->dts   = AV_NOPTS_VALUE;\n    pkt->pos   = -1;\n    pkt->duration = 0;\n    pkt->convergence_duration = 0;\n    pkt->flags = 0;\n    pkt->stream_index = 0;\n    pkt->destruct= NULL;\n}', 'static int64_t get_pts(const uint8_t *p)\n{\n    int hour, min, sec, hsec;\n    if(sscanf(p, "%*[^,],%d:%d:%d%*c%d", &hour, &min, &sec, &hsec) != 4)\n        return AV_NOPTS_VALUE;\n    min+= 60*hour;\n    sec+= 60*min;\n    return sec*100+hsec;\n}']