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>
Sat, 30 Jan 2016 23:25:19 +0000 (00:25 +0100)
Fixes: Ticket4914

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit b51e7554e74cbf007a1cab83c7bed3ad9fa2793a)

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

index 3c0283b..7ffd6b6 100644 (file)
@@ -2007,6 +2007,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;
     }