avformat/mxfenc: Do not crash if there is no packet in the first stream
authorMichael Niedermayer <michael@niedermayer.cc>
Sun, 13 Dec 2015 15:13:22 +0000 (16:13 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Sun, 13 Dec 2015 15:42:48 +0000 (16:42 +0100)
Fixes: Ticket4914

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/mxfenc.c

index 043daff..59eed2e 100644 (file)
@@ -2469,6 +2469,10 @@ static int mxf_write_packet(AVFormatContext *s, AVPacket *pkt)
         }
         mxf->edit_units_count++;
     } else if (!mxf->edit_unit_byte_count && st->index == 1) {
+        if (!mxf->edit_units_count) {
+            av_log(s, AV_LOG_ERROR, "No packets in first stream\n");
+            return AVERROR_PATCHWELCOME;
+        }
         mxf->index_entries[mxf->edit_units_count-1].slice_offset =
             mxf->body_offset - mxf->index_entries[mxf->edit_units_count-1].offset;
     }