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

libavformat/mxfenc.c:1171:1: start of procedure mxf_write_partition()
1169. }
1170. 
1171. static void mxf_write_partition(AVFormatContext *s, int bodysid,
      ^
1172.                                 int indexsid,
1173.                                 const uint8_t *key, int write_metadata)

libavformat/mxfenc.c:1175:5: 
1173.                                 const uint8_t *key, int write_metadata)
1174. {
1175.     MXFContext *mxf = s->priv_data;
          ^
1176.     ByteIOContext *pb = s->pb;
1177.     int64_t header_byte_count_offset;

libavformat/mxfenc.c:1176:5: 
1174. {
1175.     MXFContext *mxf = s->priv_data;
1176.     ByteIOContext *pb = s->pb;
          ^
1177.     int64_t header_byte_count_offset;
1178.     unsigned index_byte_count = 0;

libavformat/mxfenc.c:1178:5: 
1176.     ByteIOContext *pb = s->pb;
1177.     int64_t header_byte_count_offset;
1178.     unsigned index_byte_count = 0;
          ^
1179.     uint64_t partition_offset = url_ftell(pb);
1180. 

libavformat/mxfenc.c:1179:5: 
1177.     int64_t header_byte_count_offset;
1178.     unsigned index_byte_count = 0;
1179.     uint64_t partition_offset = url_ftell(pb);
          ^
1180. 
1181.     if (!mxf->edit_unit_byte_count && mxf->edit_units_count)

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

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

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

libavformat/mxfenc.c:1181:10: Taking true branch
1179.     uint64_t partition_offset = url_ftell(pb);
1180. 
1181.     if (!mxf->edit_unit_byte_count && mxf->edit_units_count)
               ^
1182.         index_byte_count = 85 + 12+(s->nb_streams+1)*6 +
1183.             12+mxf->edit_units_count*(11+mxf->slice_count*4);

libavformat/mxfenc.c:1181:39: Taking true branch
1179.     uint64_t partition_offset = url_ftell(pb);
1180. 
1181.     if (!mxf->edit_unit_byte_count && mxf->edit_units_count)
                                            ^
1182.         index_byte_count = 85 + 12+(s->nb_streams+1)*6 +
1183.             12+mxf->edit_units_count*(11+mxf->slice_count*4);

libavformat/mxfenc.c:1182:9: 
1180. 
1181.     if (!mxf->edit_unit_byte_count && mxf->edit_units_count)
1182.         index_byte_count = 85 + 12+(s->nb_streams+1)*6 +
              ^
1183.             12+mxf->edit_units_count*(11+mxf->slice_count*4);
1184.     else if (mxf->edit_unit_byte_count && indexsid)

libavformat/mxfenc.c:1187:9: Taking true branch
1185.         index_byte_count = 80;
1186. 
1187.     if (index_byte_count) {
              ^
1188.         // add encoded ber length
1189.         index_byte_count += 16 + klv_ber_length(index_byte_count);

libavformat/mxfenc.c:1189:9: 
1187.     if (index_byte_count) {
1188.         // add encoded ber length
1189.         index_byte_count += 16 + klv_ber_length(index_byte_count);
              ^
1190.         index_byte_count += klv_fill_size(index_byte_count);
1191.     }

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

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

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

libavutil/common.h:134:1: start of procedure av_log2()
    132. extern const uint8_t ff_log2_tab[256];
    133. 
    134. static inline av_const int av_log2(unsigned int v)
         ^
    135. {
    136.     int n = 0;

libavutil/common.h:136:5: 
    134. static inline av_const int av_log2(unsigned int v)
    135. {
    136.     int n = 0;
             ^
    137.     if (v & 0xffff0000) {
    138.         v >>= 16;

libavutil/common.h:137:9: Taking false branch
    135. {
    136.     int n = 0;
    137.     if (v & 0xffff0000) {
                 ^
    138.         v >>= 16;
    139.         n += 16;

libavutil/common.h:141:9: Taking false branch
    139.         n += 16;
    140.     }
    141.     if (v & 0xff00) {
                 ^
    142.         v >>= 8;
    143.         n += 8;

libavutil/common.h:145:5: 
    143.         n += 8;
    144.     }
    145.     n += ff_log2_tab[v];
             ^
    146. 
    147.     return n;

libavutil/common.h:147:5: 
    145.     n += ff_log2_tab[v];
    146. 
    147.     return n;
             ^
    148. }
    149. 

libavutil/common.h:148:1: return from a call to av_log2
    146. 
    147.     return n;
    148. }
         ^
    149. 
    150. static inline av_const int av_log2_16bit(unsigned int v)

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

libavformat/mxfenc.c:1190:9: 
1188.         // add encoded ber length
1189.         index_byte_count += 16 + klv_ber_length(index_byte_count);
1190.         index_byte_count += klv_fill_size(index_byte_count);
              ^
1191.     }
1192. 

libavformat/mxfenc.c:1021:1: start of procedure klv_fill_size()
  1019. }
  1020. 
  1021. static unsigned klv_fill_size(uint64_t size)
        ^
  1022. {
  1023.     unsigned pad = KAG_SIZE - (size & (KAG_SIZE-1));

libavformat/mxfenc.c:1023:5: 
  1021. static unsigned klv_fill_size(uint64_t size)
  1022. {
  1023.     unsigned pad = KAG_SIZE - (size & (KAG_SIZE-1));
            ^
  1024.     if (pad < 20) // smallest fill item possible
  1025.         return pad + KAG_SIZE;

libavformat/mxfenc.c:1024:9: Taking false branch
  1022. {
  1023.     unsigned pad = KAG_SIZE - (size & (KAG_SIZE-1));
  1024.     if (pad < 20) // smallest fill item possible
                ^
  1025.         return pad + KAG_SIZE;
  1026.     else

libavformat/mxfenc.c:1027:9: 
  1025.         return pad + KAG_SIZE;
  1026.     else
  1027.         return pad & (KAG_SIZE-1);
                ^
  1028. }
  1029. 

libavformat/mxfenc.c:1028:1: return from a call to klv_fill_size
  1026.     else
  1027.         return pad & (KAG_SIZE-1);
  1028. }
        ^
  1029. 
  1030. static void mxf_write_index_table_segment(AVFormatContext *s)

libavformat/mxfenc.c:1193:10: Taking true branch
1191.     }
1192. 
1193.     if (!memcmp(key, body_partition_key, 16)) {
               ^
1194.         mxf->body_partition_offset =
1195.             av_realloc(mxf->body_partition_offset,

libavformat/mxfenc.c:1194:9: 
1192. 
1193.     if (!memcmp(key, body_partition_key, 16)) {
1194.         mxf->body_partition_offset =
              ^
1195.             av_realloc(mxf->body_partition_offset,
1196.                        (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:1198:9: 
1196.                        (mxf->body_partitions_count+1)*
1197.                        sizeof(*mxf->body_partition_offset));
1198.         mxf->body_partition_offset[mxf->body_partitions_count++] = partition_offset;
              ^
1199.     }
1200. 
