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

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

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

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

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

libavformat/mxfenc.c:1178:5: 
1176.     int64_t header_byte_count_offset;
1177.     unsigned index_byte_count = 0;
1178.     uint64_t partition_offset = url_ftell(pb);
          ^
1179. 
1180.     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:1180:10: Taking true branch
1178.     uint64_t partition_offset = url_ftell(pb);
1179. 
1180.     if (!mxf->edit_unit_byte_count && mxf->edit_units_count)
               ^
1181.         index_byte_count = 85 + 12+(s->nb_streams+1)*6 +
1182.             12+mxf->edit_units_count*(11+mxf->slice_count*4);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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