libavformat/mxfenc.c:1211: error: Null Dereference
  pointer `mxf->body_partition_offset` last assigned on line 1207 could be null and is dereferenced at line 1211, column 9.

libavformat/mxfenc.c:1184:1: start of procedure mxf_write_partition()
1182. }
1183. 
1184. static void mxf_write_partition(AVFormatContext *s, int bodysid,
      ^
1185.                                 int indexsid,
1186.                                 const uint8_t *key, int write_metadata)

libavformat/mxfenc.c:1188:5: 
1186.                                 const uint8_t *key, int write_metadata)
1187. {
1188.     MXFContext *mxf = s->priv_data;
          ^
1189.     ByteIOContext *pb = s->pb;
1190.     int64_t header_byte_count_offset;

libavformat/mxfenc.c:1189:5: 
1187. {
1188.     MXFContext *mxf = s->priv_data;
1189.     ByteIOContext *pb = s->pb;
          ^
1190.     int64_t header_byte_count_offset;
1191.     unsigned index_byte_count = 0;

libavformat/mxfenc.c:1191:5: 
1189.     ByteIOContext *pb = s->pb;
1190.     int64_t header_byte_count_offset;
1191.     unsigned index_byte_count = 0;
          ^
1192.     uint64_t partition_offset = url_ftell(pb);
1193. 

libavformat/mxfenc.c:1192:5: 
1190.     int64_t header_byte_count_offset;
1191.     unsigned index_byte_count = 0;
1192.     uint64_t partition_offset = url_ftell(pb);
          ^
1193. 
1194.     if (!mxf->edit_unit_byte_count && mxf->edit_units_count)

libavformat/aviobuf.c:185:1: start of procedure url_ftell()
  183. }
  184. 
  185. int64_t url_ftell(ByteIOContext *s)
       ^
  186. {
  187.     return url_fseek(s, 0, SEEK_CUR);

libavformat/aviobuf.c:187:5: Skipping url_fseek(): empty list of specs
  185. int64_t url_ftell(ByteIOContext *s)
  186. {
  187.     return url_fseek(s, 0, SEEK_CUR);
           ^
  188. }
  189. 

libavformat/aviobuf.c:188:1: return from a call to url_ftell
  186. {
  187.     return url_fseek(s, 0, SEEK_CUR);
  188. }
       ^
  189. 
  190. int64_t url_fsize(ByteIOContext *s)

libavformat/mxfenc.c:1194:10: Taking true branch
1192.     uint64_t partition_offset = url_ftell(pb);
1193. 
1194.     if (!mxf->edit_unit_byte_count && mxf->edit_units_count)
               ^
1195.         index_byte_count = 85 + 12+(s->nb_streams+1)*6 +
1196.             12+mxf->edit_units_count*(11+mxf->slice_count*4);

libavformat/mxfenc.c:1194:39: Taking true branch
1192.     uint64_t partition_offset = url_ftell(pb);
1193. 
1194.     if (!mxf->edit_unit_byte_count && mxf->edit_units_count)
                                            ^
1195.         index_byte_count = 85 + 12+(s->nb_streams+1)*6 +
1196.             12+mxf->edit_units_count*(11+mxf->slice_count*4);

libavformat/mxfenc.c:1195:9: 
1193. 
1194.     if (!mxf->edit_unit_byte_count && mxf->edit_units_count)
1195.         index_byte_count = 85 + 12+(s->nb_streams+1)*6 +
              ^
1196.             12+mxf->edit_units_count*(11+mxf->slice_count*4);
1197.     else if (mxf->edit_unit_byte_count && indexsid)

libavformat/mxfenc.c:1200:9: Taking true branch
1198.         index_byte_count = 80;
1199. 
1200.     if (index_byte_count) {
              ^
1201.         // add encoded ber length
1202.         index_byte_count += 16 + klv_ber_length(index_byte_count);

libavformat/mxfenc.c:1202:9: 
1200.     if (index_byte_count) {
1201.         // add encoded ber length
1202.         index_byte_count += 16 + klv_ber_length(index_byte_count);
              ^
1203.         index_byte_count += klv_fill_size(index_byte_count);
1204.     }

libavformat/mxfenc.c:329:1: start of procedure klv_ber_length()
  327. }
  328. 
  329. static int klv_ber_length(uint64_t len)
       ^
  330. {
  331.     if (len < 128)

libavformat/mxfenc.c:331:9: Taking false branch
  329. static int klv_ber_length(uint64_t len)
  330. {
  331.     if (len < 128)
               ^
  332.         return 1;
  333.     else

libavformat/mxfenc.c:334:9: 
  332.         return 1;
  333.     else
  334.         return (av_log2(len) >> 3) + 2;
               ^
  335. }
  336. 

libavutil/common.h:141:1: start of procedure av_log2()
    139. extern const uint8_t av_reverse[256];
    140. 
    141. static inline av_const int av_log2(unsigned int v)
         ^
    142. {
    143.     int n = 0;

libavutil/common.h:143:5: 
    141. static inline av_const int av_log2(unsigned int v)
    142. {
    143.     int n = 0;
             ^
    144.     if (v & 0xffff0000) {
    145.         v >>= 16;

libavutil/common.h:144:9: Taking true branch
    142. {
    143.     int n = 0;
    144.     if (v & 0xffff0000) {
                 ^
    145.         v >>= 16;
    146.         n += 16;

libavutil/common.h:145:9: 
    143.     int n = 0;
    144.     if (v & 0xffff0000) {
    145.         v >>= 16;
                 ^
    146.         n += 16;
    147.     }

libavutil/common.h:146:9: 
    144.     if (v & 0xffff0000) {
    145.         v >>= 16;
    146.         n += 16;
                 ^
    147.     }
    148.     if (v & 0xff00) {

libavutil/common.h:148:9: Taking false branch
    146.         n += 16;
    147.     }
    148.     if (v & 0xff00) {
                 ^
    149.         v >>= 8;
    150.         n += 8;

libavutil/common.h:152:5: 
    150.         n += 8;
    151.     }
    152.     n += ff_log2_tab[v];
             ^
    153. 
    154.     return n;

libavutil/common.h:154:5: 
    152.     n += ff_log2_tab[v];
    153. 
    154.     return n;
             ^
    155. }
    156. 

libavutil/common.h:155:1: return from a call to av_log2
    153. 
    154.     return n;
    155. }
         ^
    156. 
    157. static inline av_const int av_log2_16bit(unsigned int v)

libavformat/mxfenc.c:335:1: return from a call to klv_ber_length
  333.     else
  334.         return (av_log2(len) >> 3) + 2;
  335. }
       ^
  336. 
  337. static int klv_encode_ber_length(ByteIOContext *pb, uint64_t len)

libavformat/mxfenc.c:1203:9: 
1201.         // add encoded ber length
1202.         index_byte_count += 16 + klv_ber_length(index_byte_count);
1203.         index_byte_count += klv_fill_size(index_byte_count);
              ^
1204.     }
1205. 

libavformat/mxfenc.c:1029:1: start of procedure klv_fill_size()
  1027. }
  1028. 
  1029. static unsigned klv_fill_size(uint64_t size)
        ^
  1030. {
  1031.     unsigned pad = KAG_SIZE - (size & (KAG_SIZE-1));

libavformat/mxfenc.c:1031:5: 
  1029. static unsigned klv_fill_size(uint64_t size)
  1030. {
  1031.     unsigned pad = KAG_SIZE - (size & (KAG_SIZE-1));
            ^
  1032.     if (pad < 20) // smallest fill item possible
  1033.         return pad + KAG_SIZE;

libavformat/mxfenc.c:1032:9: Taking false branch
  1030. {
  1031.     unsigned pad = KAG_SIZE - (size & (KAG_SIZE-1));
  1032.     if (pad < 20) // smallest fill item possible
                ^
  1033.         return pad + KAG_SIZE;
  1034.     else

libavformat/mxfenc.c:1035:9: 
  1033.         return pad + KAG_SIZE;
  1034.     else
  1035.         return pad & (KAG_SIZE-1);
                ^
  1036. }
  1037. 

libavformat/mxfenc.c:1036:1: return from a call to klv_fill_size
  1034.     else
  1035.         return pad & (KAG_SIZE-1);
  1036. }
        ^
  1037. 
  1038. static void mxf_write_index_table_segment(AVFormatContext *s)

libavformat/mxfenc.c:1206:10: Taking true branch
1204.     }
1205. 
1206.     if (!memcmp(key, body_partition_key, 16)) {
               ^
1207.         mxf->body_partition_offset =
1208.             av_realloc(mxf->body_partition_offset,

libavformat/mxfenc.c:1207:9: 
1205. 
1206.     if (!memcmp(key, body_partition_key, 16)) {
1207.         mxf->body_partition_offset =
              ^
1208.             av_realloc(mxf->body_partition_offset,
1209.                        (mxf->body_partitions_count+1)*

libavutil/mem.c:102:1: start of procedure av_realloc()
  100. }
  101. 
  102. void *av_realloc(void *ptr, unsigned int size)
       ^
  103. {
  104. #if CONFIG_MEMALIGN_HACK

libavutil/mem.c:109:8: Taking true branch
  107. 
  108.     /* let's disallow possible ambiguous cases */
  109.     if(size > (INT_MAX-16) )
              ^
  110.         return NULL;
  111. 

libavutil/mem.c:110:9: 
  108.     /* let's disallow possible ambiguous cases */
  109.     if(size > (INT_MAX-16) )
  110.         return NULL;
               ^
  111. 
  112. #if CONFIG_MEMALIGN_HACK

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

libavformat/mxfenc.c:1211:9: 
1209.                        (mxf->body_partitions_count+1)*
1210.                        sizeof(*mxf->body_partition_offset));
1211.         mxf->body_partition_offset[mxf->body_partitions_count++] = partition_offset;
              ^
1212.     }
1213. 
