libavformat/movenc.c:2012: error: Null Dereference
  pointer `pkt.data` last assigned on line 2011 could be null and is dereferenced at line 2012, column 13.

libavformat/movenc.c:1987:1: start of procedure mov_create_chapter_track()
1985. // QuickTime chapters involve an additional text track with the chapter names
1986. // as samples, and a tref pointing from the other tracks to the chapter one.
1987. static void mov_create_chapter_track(AVFormatContext *s, int tracknum)
      ^
1988. {
1989.     MOVMuxContext *mov = s->priv_data;

libavformat/movenc.c:1989:5: 
1987. static void mov_create_chapter_track(AVFormatContext *s, int tracknum)
1988. {
1989.     MOVMuxContext *mov = s->priv_data;
          ^
1990.     MOVTrack *track = &mov->tracks[tracknum];
1991.     AVPacket pkt = { .stream_index = tracknum, .flags = AV_PKT_FLAG_KEY };

libavformat/movenc.c:1990:5: 
1988. {
1989.     MOVMuxContext *mov = s->priv_data;
1990.     MOVTrack *track = &mov->tracks[tracknum];
          ^
1991.     AVPacket pkt = { .stream_index = tracknum, .flags = AV_PKT_FLAG_KEY };
1992.     int i, len;

libavformat/movenc.c:1991:5: 
1989.     MOVMuxContext *mov = s->priv_data;
1990.     MOVTrack *track = &mov->tracks[tracknum];
1991.     AVPacket pkt = { .stream_index = tracknum, .flags = AV_PKT_FLAG_KEY };
          ^
1992.     int i, len;
1993. 

libavformat/movenc.c:1994:5: 
1992.     int i, len;
1993. 
1994.     track->mode = mov->mode;
          ^
1995.     track->tag = MKTAG('t','e','x','t');
1996.     track->timescale = MOV_TIMESCALE;

libavformat/movenc.c:1995:5: 
1993. 
1994.     track->mode = mov->mode;
1995.     track->tag = MKTAG('t','e','x','t');
          ^
1996.     track->timescale = MOV_TIMESCALE;
1997.     track->enc = avcodec_alloc_context();

libavformat/movenc.c:1996:5: 
1994.     track->mode = mov->mode;
1995.     track->tag = MKTAG('t','e','x','t');
1996.     track->timescale = MOV_TIMESCALE;
          ^
1997.     track->enc = avcodec_alloc_context();
1998.     track->enc->codec_type = AVMEDIA_TYPE_SUBTITLE;

libavformat/movenc.c:1997:5: 
1995.     track->tag = MKTAG('t','e','x','t');
1996.     track->timescale = MOV_TIMESCALE;
1997.     track->enc = avcodec_alloc_context();
          ^
1998.     track->enc->codec_type = AVMEDIA_TYPE_SUBTITLE;
1999. 

libavcodec/options.c:520:1: start of procedure avcodec_alloc_context()
  518. }
  519. 
  520. AVCodecContext *avcodec_alloc_context(void){
       ^
  521.     return avcodec_alloc_context2(AVMEDIA_TYPE_UNKNOWN);
  522. }

libavcodec/options.c:521:5: 
  519. 
  520. AVCodecContext *avcodec_alloc_context(void){
  521.     return avcodec_alloc_context2(AVMEDIA_TYPE_UNKNOWN);
           ^
  522. }
  523. 

libavcodec/options.c:506:1: start of procedure avcodec_alloc_context2()
    504. }
    505. 
    506. AVCodecContext *avcodec_alloc_context2(enum AVMediaType codec_type){
         ^
    507.     AVCodecContext *avctx= av_malloc(sizeof(AVCodecContext));
    508. 

libavcodec/options.c:507:5: 
    505. 
    506. AVCodecContext *avcodec_alloc_context2(enum AVMediaType codec_type){
    507.     AVCodecContext *avctx= av_malloc(sizeof(AVCodecContext));
             ^
    508. 
    509.     if(avctx==NULL) return NULL;

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 false branch
      70. 
      71.     /* let's disallow possible ambiguous cases */
      72.     if(size > (INT_MAX-16) )
                 ^
      73.         return NULL;
      74. 

libavutil/mem.c:83:9: Taking false branch
      81.     ((char*)ptr)[-1]= diff;
      82. #elif HAVE_POSIX_MEMALIGN
      83.     if (posix_memalign(&ptr,16,size))
                  ^
      84.         ptr = NULL;
      85. #elif HAVE_MEMALIGN

libavutil/mem.c:116:5: 
      114.     ptr = malloc(size);
      115. #endif
      116.     return ptr;
               ^
      117. }
      118. 

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)

libavcodec/options.c:509:8: Taking false branch
    507.     AVCodecContext *avctx= av_malloc(sizeof(AVCodecContext));
    508. 
    509.     if(avctx==NULL) return NULL;
                ^
    510. 
    511.     avcodec_get_context_defaults2(avctx, codec_type);

libavcodec/options.c:511:5: Skipping avcodec_get_context_defaults2(): empty list of specs
    509.     if(avctx==NULL) return NULL;
    510. 
    511.     avcodec_get_context_defaults2(avctx, codec_type);
             ^
    512. 
    513.     return avctx;

libavcodec/options.c:513:5: 
    511.     avcodec_get_context_defaults2(avctx, codec_type);
    512. 
    513.     return avctx;
             ^
    514. }
    515. 

libavcodec/options.c:514:1: return from a call to avcodec_alloc_context2
    512. 
    513.     return avctx;
    514. }
         ^
    515. 
    516. void avcodec_get_context_defaults(AVCodecContext *s){

libavcodec/options.c:522:1: return from a call to avcodec_alloc_context
  520. AVCodecContext *avcodec_alloc_context(void){
  521.     return avcodec_alloc_context2(AVMEDIA_TYPE_UNKNOWN);
  522. }
       ^
  523. 
  524. int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src)

libavformat/movenc.c:1998:5: 
1996.     track->timescale = MOV_TIMESCALE;
1997.     track->enc = avcodec_alloc_context();
1998.     track->enc->codec_type = AVMEDIA_TYPE_SUBTITLE;
          ^
1999. 
2000.     for (i = 0; i < s->nb_chapters; i++) {

libavformat/movenc.c:2000:10: 
1998.     track->enc->codec_type = AVMEDIA_TYPE_SUBTITLE;
1999. 
2000.     for (i = 0; i < s->nb_chapters; i++) {
               ^
2001.         AVChapter *c = s->chapters[i];
2002.         AVMetadataTag *t;

libavformat/movenc.c:2000:17: Loop condition is true. Entering loop body
1998.     track->enc->codec_type = AVMEDIA_TYPE_SUBTITLE;
1999. 
2000.     for (i = 0; i < s->nb_chapters; i++) {
                      ^
2001.         AVChapter *c = s->chapters[i];
2002.         AVMetadataTag *t;

libavformat/movenc.c:2001:9: 
1999. 
2000.     for (i = 0; i < s->nb_chapters; i++) {
2001.         AVChapter *c = s->chapters[i];
              ^
2002.         AVMetadataTag *t;
2003. 

libavformat/movenc.c:2004:9: 
2002.         AVMetadataTag *t;
2003. 
2004.         int64_t end = av_rescale_q(c->end, c->time_base, (AVRational){1,MOV_TIMESCALE});
              ^
2005.         pkt.pts = pkt.dts = av_rescale_q(c->start, c->time_base, (AVRational){1,MOV_TIMESCALE});
2006.         pkt.duration = end - pkt.dts;

libavutil/mathematics.c:133:1: start of procedure av_rescale_q()
  131. }
  132. 
  133. int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq){
       ^
  134.     int64_t b= bq.num * (int64_t)cq.den;
  135.     int64_t c= cq.num * (int64_t)bq.den;

libavutil/mathematics.c:134:5: 
  132. 
  133. int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq){
  134.     int64_t b= bq.num * (int64_t)cq.den;
           ^
  135.     int64_t c= cq.num * (int64_t)bq.den;
  136.     return av_rescale_rnd(a, b, c, AV_ROUND_NEAR_INF);

libavutil/mathematics.c:135:5: 
  133. int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq){
  134.     int64_t b= bq.num * (int64_t)cq.den;
  135.     int64_t c= cq.num * (int64_t)bq.den;
           ^
  136.     return av_rescale_rnd(a, b, c, AV_ROUND_NEAR_INF);
  137. }

libavutil/mathematics.c:136:5: Skipping av_rescale_rnd(): empty list of specs
  134.     int64_t b= bq.num * (int64_t)cq.den;
  135.     int64_t c= cq.num * (int64_t)bq.den;
  136.     return av_rescale_rnd(a, b, c, AV_ROUND_NEAR_INF);
           ^
  137. }
  138. 

libavutil/mathematics.c:137:1: return from a call to av_rescale_q
  135.     int64_t c= cq.num * (int64_t)bq.den;
  136.     return av_rescale_rnd(a, b, c, AV_ROUND_NEAR_INF);
  137. }
       ^
  138. 
  139. int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b){

libavformat/movenc.c:2005:9: 
2003. 
2004.         int64_t end = av_rescale_q(c->end, c->time_base, (AVRational){1,MOV_TIMESCALE});
2005.         pkt.pts = pkt.dts = av_rescale_q(c->start, c->time_base, (AVRational){1,MOV_TIMESCALE});
              ^
2006.         pkt.duration = end - pkt.dts;
2007. 

libavutil/mathematics.c:133:1: start of procedure av_rescale_q()
  131. }
  132. 
  133. int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq){
       ^
  134.     int64_t b= bq.num * (int64_t)cq.den;
  135.     int64_t c= cq.num * (int64_t)bq.den;

libavutil/mathematics.c:134:5: 
  132. 
  133. int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq){
  134.     int64_t b= bq.num * (int64_t)cq.den;
           ^
  135.     int64_t c= cq.num * (int64_t)bq.den;
  136.     return av_rescale_rnd(a, b, c, AV_ROUND_NEAR_INF);

libavutil/mathematics.c:135:5: 
  133. int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq){
  134.     int64_t b= bq.num * (int64_t)cq.den;
  135.     int64_t c= cq.num * (int64_t)bq.den;
           ^
  136.     return av_rescale_rnd(a, b, c, AV_ROUND_NEAR_INF);
  137. }

libavutil/mathematics.c:136:5: Skipping av_rescale_rnd(): empty list of specs
  134.     int64_t b= bq.num * (int64_t)cq.den;
  135.     int64_t c= cq.num * (int64_t)bq.den;
  136.     return av_rescale_rnd(a, b, c, AV_ROUND_NEAR_INF);
           ^
  137. }
  138. 

libavutil/mathematics.c:137:1: return from a call to av_rescale_q
  135.     int64_t c= cq.num * (int64_t)bq.den;
  136.     return av_rescale_rnd(a, b, c, AV_ROUND_NEAR_INF);
  137. }
       ^
  138. 
  139. int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b){

libavformat/movenc.c:2006:9: 
2004.         int64_t end = av_rescale_q(c->end, c->time_base, (AVRational){1,MOV_TIMESCALE});
2005.         pkt.pts = pkt.dts = av_rescale_q(c->start, c->time_base, (AVRational){1,MOV_TIMESCALE});
2006.         pkt.duration = end - pkt.dts;
              ^
2007. 
2008.         if ((t = av_metadata_get(c->metadata, "title", NULL, 0))) {

libavformat/movenc.c:2008:14: Taking true branch
2006.         pkt.duration = end - pkt.dts;
2007. 
2008.         if ((t = av_metadata_get(c->metadata, "title", NULL, 0))) {
                   ^
2009.             len = strlen(t->value);
2010.             pkt.size = len+2;

libavformat/movenc.c:2009:13: 
2007. 
2008.         if ((t = av_metadata_get(c->metadata, "title", NULL, 0))) {
2009.             len = strlen(t->value);
                  ^
2010.             pkt.size = len+2;
2011.             pkt.data = av_malloc(pkt.size);

libavformat/movenc.c:2010:13: 
2008.         if ((t = av_metadata_get(c->metadata, "title", NULL, 0))) {
2009.             len = strlen(t->value);
2010.             pkt.size = len+2;
                  ^
2011.             pkt.data = av_malloc(pkt.size);
2012.             AV_WB16(pkt.data, len);

libavformat/movenc.c:2011:13: 
2009.             len = strlen(t->value);
2010.             pkt.size = len+2;
2011.             pkt.data = av_malloc(pkt.size);
                  ^
2012.             AV_WB16(pkt.data, len);
2013.             memcpy(pkt.data+2, t->value, len);

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)

libavformat/movenc.c:2012:13: 
2010.             pkt.size = len+2;
2011.             pkt.data = av_malloc(pkt.size);
2012.             AV_WB16(pkt.data, len);
                  ^
2013.             memcpy(pkt.data+2, t->value, len);
2014.             ff_mov_write_packet(s, &pkt);

libavutil/bswap.h:58:1: start of procedure av_bswap16()
  56. 
  57. #ifndef av_bswap16
  58. static av_always_inline av_const uint16_t av_bswap16(uint16_t x)
      ^
  59. {
  60.     x= (x>>8) | (x<<8);

libavutil/bswap.h:60:5: 
  58. static av_always_inline av_const uint16_t av_bswap16(uint16_t x)
  59. {
  60.     x= (x>>8) | (x<<8);
          ^
  61.     return x;
  62. }

libavutil/bswap.h:61:5: 
  59. {
  60.     x= (x>>8) | (x<<8);
  61.     return x;
          ^
  62. }
  63. #endif

libavutil/bswap.h:62:1: return from a call to av_bswap16
  60.     x= (x>>8) | (x<<8);
  61.     return x;
  62. }
      ^
  63. #endif
  64. 
