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

libavformat/mxfenc.c:1178:1: start of procedure mxf_write_partition()
1176. }
1177. 
1178. static void mxf_write_partition(AVFormatContext *s, int bodysid,
      ^
1179.                                 int indexsid,
1180.                                 const uint8_t *key, int write_metadata)

libavformat/mxfenc.c:1182:5: 
1180.                                 const uint8_t *key, int write_metadata)
1181. {
1182.     MXFContext *mxf = s->priv_data;
          ^
1183.     ByteIOContext *pb = s->pb;
1184.     int64_t header_byte_count_offset;

libavformat/mxfenc.c:1183:5: 
1181. {
1182.     MXFContext *mxf = s->priv_data;
1183.     ByteIOContext *pb = s->pb;
          ^
1184.     int64_t header_byte_count_offset;
1185.     unsigned index_byte_count = 0;

libavformat/mxfenc.c:1185:5: 
1183.     ByteIOContext *pb = s->pb;
1184.     int64_t header_byte_count_offset;
1185.     unsigned index_byte_count = 0;
          ^
1186.     uint64_t partition_offset = url_ftell(pb);
1187. 

libavformat/mxfenc.c:1186:5: 
1184.     int64_t header_byte_count_offset;
1185.     unsigned index_byte_count = 0;
1186.     uint64_t partition_offset = url_ftell(pb);
          ^
1187. 
1188.     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:1188:10: Taking true branch
1186.     uint64_t partition_offset = url_ftell(pb);
1187. 
1188.     if (!mxf->edit_unit_byte_count && mxf->edit_units_count)
               ^
1189.         index_byte_count = 85 + 12+(s->nb_streams+1)*6 +
1190.             12+mxf->edit_units_count*(11+mxf->slice_count*4);

libavformat/mxfenc.c:1188:39: Taking true branch
1186.     uint64_t partition_offset = url_ftell(pb);
1187. 
1188.     if (!mxf->edit_unit_byte_count && mxf->edit_units_count)
                                            ^
1189.         index_byte_count = 85 + 12+(s->nb_streams+1)*6 +
1190.             12+mxf->edit_units_count*(11+mxf->slice_count*4);

libavformat/mxfenc.c:1189:9: 
1187. 
1188.     if (!mxf->edit_unit_byte_count && mxf->edit_units_count)
1189.         index_byte_count = 85 + 12+(s->nb_streams+1)*6 +
              ^
1190.             12+mxf->edit_units_count*(11+mxf->slice_count*4);
1191.     else if (mxf->edit_unit_byte_count && indexsid)

libavformat/mxfenc.c:1194:9: Taking true branch
1192.         index_byte_count = 85;
1193. 
1194.     if (index_byte_count) {
              ^
1195.         // add encoded ber length
1196.         index_byte_count += 16 + klv_ber_length(index_byte_count);

libavformat/mxfenc.c:1196:9: 
1194.     if (index_byte_count) {
1195.         // add encoded ber length
1196.         index_byte_count += 16 + klv_ber_length(index_byte_count);
              ^
1197.         index_byte_count += klv_fill_size(index_byte_count);
1198.     }

libavformat/mxfenc.c:321:1: start of procedure klv_ber_length()
  319. }
  320. 
  321. static int klv_ber_length(uint64_t len)
       ^
  322. {
  323.     if (len < 128)

libavformat/mxfenc.c:323:9: Taking false branch
  321. static int klv_ber_length(uint64_t len)
  322. {
  323.     if (len < 128)
               ^
  324.         return 1;
  325.     else

libavformat/mxfenc.c:326:9: 
  324.         return 1;
  325.     else
  326.         return (av_log2(len) >> 3) + 2;
               ^
  327. }
  328. 

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

libavutil/common.h:132:5: 
    130. static inline av_const int av_log2(unsigned int v)
    131. {
    132.     int n = 0;
             ^
    133.     if (v & 0xffff0000) {
    134.         v >>= 16;

libavutil/common.h:133:9: Taking false branch
    131. {
    132.     int n = 0;
    133.     if (v & 0xffff0000) {
                 ^
    134.         v >>= 16;
    135.         n += 16;

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

libavutil/common.h:141:5: 
    139.         n += 8;
    140.     }
    141.     n += ff_log2_tab[v];
             ^
    142. 
    143.     return n;

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

libavutil/common.h:144:1: return from a call to av_log2
    142. 
    143.     return n;
    144. }
         ^
    145. 
    146. static inline av_const int av_log2_16bit(unsigned int v)

libavformat/mxfenc.c:327:1: return from a call to klv_ber_length
  325.     else
  326.         return (av_log2(len) >> 3) + 2;
  327. }
       ^
  328. 
  329. static int klv_encode_ber_length(ByteIOContext *pb, uint64_t len)

libavformat/mxfenc.c:1197:9: 
1195.         // add encoded ber length
1196.         index_byte_count += 16 + klv_ber_length(index_byte_count);
1197.         index_byte_count += klv_fill_size(index_byte_count);
              ^
1198.     }
1199. 

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

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

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

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

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

libavformat/mxfenc.c:1200:10: Taking true branch
1198.     }
1199. 
1200.     if (!memcmp(key, body_partition_key, 16)) {
               ^
1201.         mxf->body_partition_offset =
1202.             av_realloc(mxf->body_partition_offset,

libavformat/mxfenc.c:1201:9: 
1199. 
1200.     if (!memcmp(key, body_partition_key, 16)) {
1201.         mxf->body_partition_offset =
              ^
1202.             av_realloc(mxf->body_partition_offset,
1203.                        (mxf->body_partitions_count+1)*

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

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

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

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

libavformat/mxfenc.c:1205:9: 
1203.                        (mxf->body_partitions_count+1)*
1204.                        sizeof(*mxf->body_partition_offset));
1205.         mxf->body_partition_offset[mxf->body_partitions_count++] = partition_offset;
              ^
1206.     }
1207. 
