diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 98913dfdb6..5a83e8af89 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -2653,6 +2653,8 @@ static int matroska_read_header(AVFormatContext *s) goto fail; pos = avio_tell(matroska->ctx->pb); res = ebml_parse(matroska, matroska_segment, matroska); + if (res == AVERROR(EIO)) // EOF is translated to EIO, this exists the loop on EOF + goto fail; } matroska_execute_seekhead(matroska);