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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

libavutil/common.h:60:1: start of procedure av_log2_c()
    58. extern const uint8_t av_reverse[256];
    59. 
    60. static inline av_const int av_log2_c(unsigned int v)
        ^
    61. {
    62.     int n = 0;

libavutil/common.h:62:5: 
    60. static inline av_const int av_log2_c(unsigned int v)
    61. {
    62.     int n = 0;
            ^
    63.     if (v & 0xffff0000) {
    64.         v >>= 16;

libavutil/common.h:63:9: Taking true branch
    61. {
    62.     int n = 0;
    63.     if (v & 0xffff0000) {
                ^
    64.         v >>= 16;
    65.         n += 16;

libavutil/common.h:64:9: 
    62.     int n = 0;
    63.     if (v & 0xffff0000) {
    64.         v >>= 16;
                ^
    65.         n += 16;
    66.     }

libavutil/common.h:65:9: 
    63.     if (v & 0xffff0000) {
    64.         v >>= 16;
    65.         n += 16;
                ^
    66.     }
    67.     if (v & 0xff00) {

libavutil/common.h:67:9: Taking false branch
    65.         n += 16;
    66.     }
    67.     if (v & 0xff00) {
                ^
    68.         v >>= 8;
    69.         n += 8;

libavutil/common.h:71:5: 
    69.         n += 8;
    70.     }
    71.     n += ff_log2_tab[v];
            ^
    72. 
    73.     return n;

libavutil/common.h:73:5: 
    71.     n += ff_log2_tab[v];
    72. 
    73.     return n;
            ^
    74. }
    75. 

libavutil/common.h:74:1: return from a call to av_log2_c
    72. 
    73.     return n;
    74. }
        ^
    75. 
    76. static inline av_const int av_log2_16bit_c(unsigned int v)

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

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

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

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

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

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

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

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

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

libavutil/mem.c:119:1: start of procedure av_realloc()
  117. }
  118. 
  119. void *av_realloc(void *ptr, unsigned int size)
       ^
  120. {
  121. #if CONFIG_MEMALIGN_HACK

libavutil/mem.c:126:8: Taking true branch
  124. 
  125.     /* let's disallow possible ambiguous cases */
  126.     if(size > (INT_MAX-16) )
              ^
  127.         return NULL;
  128. 

libavutil/mem.c:127:9: 
  125.     /* let's disallow possible ambiguous cases */
  126.     if(size > (INT_MAX-16) )
  127.         return NULL;
               ^
  128. 
  129. #if CONFIG_MEMALIGN_HACK

libavutil/mem.c:137:1: return from a call to av_realloc
  135.     return realloc(ptr, size);
  136. #endif
  137. }
       ^
  138. 
  139. void av_free(void *ptr)

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