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

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

libavformat/movenc.c:2961:5: 
2959. static void mov_create_chapter_track(AVFormatContext *s, int tracknum)
2960. {
2961.     MOVMuxContext *mov = s->priv_data;
          ^
2962.     MOVTrack *track = &mov->tracks[tracknum];
2963.     AVPacket pkt = { .stream_index = tracknum, .flags = AV_PKT_FLAG_KEY };

libavformat/movenc.c:2962:5: 
2960. {
2961.     MOVMuxContext *mov = s->priv_data;
2962.     MOVTrack *track = &mov->tracks[tracknum];
          ^
2963.     AVPacket pkt = { .stream_index = tracknum, .flags = AV_PKT_FLAG_KEY };
2964.     int i, len;

libavformat/movenc.c:2963:5: 
2961.     MOVMuxContext *mov = s->priv_data;
2962.     MOVTrack *track = &mov->tracks[tracknum];
2963.     AVPacket pkt = { .stream_index = tracknum, .flags = AV_PKT_FLAG_KEY };
          ^
2964.     int i, len;
2965. 

libavformat/movenc.c:2966:5: 
2964.     int i, len;
2965. 
2966.     track->mode = mov->mode;
          ^
2967.     track->tag = MKTAG('t','e','x','t');
2968.     track->timescale = MOV_TIMESCALE;

libavformat/movenc.c:2967:5: 
2965. 
2966.     track->mode = mov->mode;
2967.     track->tag = MKTAG('t','e','x','t');
          ^
2968.     track->timescale = MOV_TIMESCALE;
2969.     track->enc = avcodec_alloc_context3(NULL);

libavformat/movenc.c:2968:5: 
2966.     track->mode = mov->mode;
2967.     track->tag = MKTAG('t','e','x','t');
2968.     track->timescale = MOV_TIMESCALE;
          ^
2969.     track->enc = avcodec_alloc_context3(NULL);
2970.     track->enc->codec_type = AVMEDIA_TYPE_SUBTITLE;

libavformat/movenc.c:2969:5: 
2967.     track->tag = MKTAG('t','e','x','t');
2968.     track->timescale = MOV_TIMESCALE;
2969.     track->enc = avcodec_alloc_context3(NULL);
          ^
2970.     track->enc->codec_type = AVMEDIA_TYPE_SUBTITLE;
2971. 

libavcodec/options.c:126:1: start of procedure avcodec_alloc_context3()
  124. }
  125. 
  126. AVCodecContext *avcodec_alloc_context3(const AVCodec *codec)
       ^
  127. {
  128.     AVCodecContext *avctx= av_malloc(sizeof(AVCodecContext));

libavcodec/options.c:128:5: 
  126. AVCodecContext *avcodec_alloc_context3(const AVCodec *codec)
  127. {
  128.     AVCodecContext *avctx= av_malloc(sizeof(AVCodecContext));
           ^
  129. 
  130.     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(size_t size)
        ^
    65. {
    66.     void *ptr = NULL;

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

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

libavutil/mem.c:72:33: Taking false branch
    70. 
    71.     /* let's disallow possible ambiguous cases */
    72.     if (size > (INT_MAX-32) || !size)
                                        ^
    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,32,size))
                ^
    84.         ptr = NULL;
    85. #elif HAVE_ALIGNED_MALLOC

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, size_t size)

libavcodec/options.c:130:8: Taking false branch
  128.     AVCodecContext *avctx= av_malloc(sizeof(AVCodecContext));
  129. 
  130.     if(avctx==NULL) return NULL;
              ^
  131. 
  132.     if(avcodec_get_context_defaults3(avctx, codec) < 0){

libavcodec/options.c:132:8: Taking false branch
  130.     if(avctx==NULL) return NULL;
  131. 
  132.     if(avcodec_get_context_defaults3(avctx, codec) < 0){
              ^
  133.         av_free(avctx);
  134.         return NULL;

libavcodec/options.c:137:5: 
  135.     }
  136. 
  137.     return avctx;
           ^
  138. }
  139. 

libavcodec/options.c:138:1: return from a call to avcodec_alloc_context3
  136. 
  137.     return avctx;
  138. }
       ^
  139. 
  140. int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src)

libavformat/movenc.c:2970:5: 
2968.     track->timescale = MOV_TIMESCALE;
2969.     track->enc = avcodec_alloc_context3(NULL);
2970.     track->enc->codec_type = AVMEDIA_TYPE_SUBTITLE;
          ^
2971. 
2972.     for (i = 0; i < s->nb_chapters; i++) {

libavformat/movenc.c:2972:10: 
2970.     track->enc->codec_type = AVMEDIA_TYPE_SUBTITLE;
2971. 
2972.     for (i = 0; i < s->nb_chapters; i++) {
               ^
2973.         AVChapter *c = s->chapters[i];
2974.         AVDictionaryEntry *t;

libavformat/movenc.c:2972:17: Loop condition is true. Entering loop body
2970.     track->enc->codec_type = AVMEDIA_TYPE_SUBTITLE;
2971. 
2972.     for (i = 0; i < s->nb_chapters; i++) {
                      ^
2973.         AVChapter *c = s->chapters[i];
2974.         AVDictionaryEntry *t;

libavformat/movenc.c:2973:9: 
2971. 
2972.     for (i = 0; i < s->nb_chapters; i++) {
2973.         AVChapter *c = s->chapters[i];
              ^
2974.         AVDictionaryEntry *t;
2975. 

libavformat/movenc.c:2976:9: 
2974.         AVDictionaryEntry *t;
2975. 
2976.         int64_t end = av_rescale_q(c->end, c->time_base, (AVRational){1,MOV_TIMESCALE});
              ^
2977.         pkt.pts = pkt.dts = av_rescale_q(c->start, c->time_base, (AVRational){1,MOV_TIMESCALE});
2978.         pkt.duration = end - pkt.dts;

libavutil/mathematics.c:141:1: start of procedure av_rescale_q()
  139. }
  140. 
  141. int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
       ^
  142. {
  143.     return av_rescale_q_rnd(a, bq, cq, AV_ROUND_NEAR_INF);

libavutil/mathematics.c:143:5: 
  141. int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
  142. {
  143.     return av_rescale_q_rnd(a, bq, cq, AV_ROUND_NEAR_INF);
           ^
  144. }
  145. 

libavutil/mathematics.c:133:1: start of procedure av_rescale_q_rnd()
    131. }
    132. 
    133. int64_t av_rescale_q_rnd(int64_t a, AVRational bq, AVRational cq,
         ^
    134.                          enum AVRounding rnd)
    135. {

libavutil/mathematics.c:136:5: 
    134.                          enum AVRounding rnd)
    135. {
    136.     int64_t b= bq.num * (int64_t)cq.den;
             ^
    137.     int64_t c= cq.num * (int64_t)bq.den;
    138.     return av_rescale_rnd(a, b, c, rnd);

libavutil/mathematics.c:137:5: 
    135. {
    136.     int64_t b= bq.num * (int64_t)cq.den;
    137.     int64_t c= cq.num * (int64_t)bq.den;
             ^
    138.     return av_rescale_rnd(a, b, c, rnd);
    139. }

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

libavutil/mathematics.c:139:1: return from a call to av_rescale_q_rnd
    137.     int64_t c= cq.num * (int64_t)bq.den;
    138.     return av_rescale_rnd(a, b, c, rnd);
    139. }
         ^
    140. 
    141. int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)

libavutil/mathematics.c:144:1: return from a call to av_rescale_q
  142. {
  143.     return av_rescale_q_rnd(a, bq, cq, AV_ROUND_NEAR_INF);
  144. }
       ^
  145. 
  146. int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b){

libavformat/movenc.c:2977:9: 
2975. 
2976.         int64_t end = av_rescale_q(c->end, c->time_base, (AVRational){1,MOV_TIMESCALE});
2977.         pkt.pts = pkt.dts = av_rescale_q(c->start, c->time_base, (AVRational){1,MOV_TIMESCALE});
              ^
2978.         pkt.duration = end - pkt.dts;
2979. 

libavutil/mathematics.c:141:1: start of procedure av_rescale_q()
  139. }
  140. 
  141. int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
       ^
  142. {
  143.     return av_rescale_q_rnd(a, bq, cq, AV_ROUND_NEAR_INF);

libavutil/mathematics.c:143:5: 
  141. int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
  142. {
  143.     return av_rescale_q_rnd(a, bq, cq, AV_ROUND_NEAR_INF);
           ^
  144. }
  145. 

libavutil/mathematics.c:133:1: start of procedure av_rescale_q_rnd()
    131. }
    132. 
    133. int64_t av_rescale_q_rnd(int64_t a, AVRational bq, AVRational cq,
         ^
    134.                          enum AVRounding rnd)
    135. {

libavutil/mathematics.c:136:5: 
    134.                          enum AVRounding rnd)
    135. {
    136.     int64_t b= bq.num * (int64_t)cq.den;
             ^
    137.     int64_t c= cq.num * (int64_t)bq.den;
    138.     return av_rescale_rnd(a, b, c, rnd);

libavutil/mathematics.c:137:5: 
    135. {
    136.     int64_t b= bq.num * (int64_t)cq.den;
    137.     int64_t c= cq.num * (int64_t)bq.den;
             ^
    138.     return av_rescale_rnd(a, b, c, rnd);
    139. }

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

libavutil/mathematics.c:139:1: return from a call to av_rescale_q_rnd
    137.     int64_t c= cq.num * (int64_t)bq.den;
    138.     return av_rescale_rnd(a, b, c, rnd);
    139. }
         ^
    140. 
    141. int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)

libavutil/mathematics.c:144:1: return from a call to av_rescale_q
  142. {
  143.     return av_rescale_q_rnd(a, bq, cq, AV_ROUND_NEAR_INF);
  144. }
       ^
  145. 
  146. int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b){

libavformat/movenc.c:2978:9: 
2976.         int64_t end = av_rescale_q(c->end, c->time_base, (AVRational){1,MOV_TIMESCALE});
2977.         pkt.pts = pkt.dts = av_rescale_q(c->start, c->time_base, (AVRational){1,MOV_TIMESCALE});
2978.         pkt.duration = end - pkt.dts;
              ^
2979. 
2980.         if ((t = av_dict_get(c->metadata, "title", NULL, 0))) {

libavformat/movenc.c:2980:14: Taking true branch
2978.         pkt.duration = end - pkt.dts;
2979. 
2980.         if ((t = av_dict_get(c->metadata, "title", NULL, 0))) {
                   ^
2981.             len = strlen(t->value);
2982.             pkt.size = len+2;

libavformat/movenc.c:2981:13: 
2979. 
2980.         if ((t = av_dict_get(c->metadata, "title", NULL, 0))) {
2981.             len = strlen(t->value);
                  ^
2982.             pkt.size = len+2;
2983.             pkt.data = av_malloc(pkt.size);

libavformat/movenc.c:2982:13: 
2980.         if ((t = av_dict_get(c->metadata, "title", NULL, 0))) {
2981.             len = strlen(t->value);
2982.             pkt.size = len+2;
                  ^
2983.             pkt.data = av_malloc(pkt.size);
2984.             AV_WB16(pkt.data, len);

libavformat/movenc.c:2983:13: 
2981.             len = strlen(t->value);
2982.             pkt.size = len+2;
2983.             pkt.data = av_malloc(pkt.size);
                  ^
2984.             AV_WB16(pkt.data, len);
2985.             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(size_t size)
      ^
  65. {
  66.     void *ptr = NULL;

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

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

libavutil/mem.c:73:9: 
  71.     /* let's disallow possible ambiguous cases */
  72.     if (size > (INT_MAX-32) || !size)
  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, size_t size)

libavformat/movenc.c:2984:13: 
2982.             pkt.size = len+2;
2983.             pkt.data = av_malloc(pkt.size);
2984.             AV_WB16(pkt.data, len);
                  ^
2985.             memcpy(pkt.data+2, t->value, len);
2986.             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. 
