[FFmpeg-devel] [PATCH 1/8] avformat/matroskadec: Don't overlook parsing error

Andreas Rheinhardt andreas.rheinhardt at gmail.com
Thu Sep 5 23:16:02 EEST 2019


If one isn't in a cluster initially, matroska_parse_cluster would test
whether the next element is a cluster. Said test can fail and if it
failed, the error would be returned until 71c90881. But 71c90881 changed
this inadvertently: If the element found is an unknown-length element that
is intended to be skipped, but can't (because of its unknown length),
it is entered and if an error happens during parsing its children, it is
possible that one is on level 2 after the initial test. This will then
be treated as if one were inside a cluster and an attempt is made to
parse SimpleBlocks/BlockGroups in which case the original error will be
overwritten and overlooked. This commit fixes this.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
---
 libavformat/matroskadec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 8c4ff30935..0c881a67e8 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -3686,9 +3686,9 @@ static int matroska_parse_cluster(MatroskaDemuxContext *matroska)
             cluster->pos = avio_tell(matroska->ctx->pb) - 4;
 
             res = ebml_parse(matroska, matroska_cluster_enter, cluster);
-            if (res < 0)
-                return res;
         }
+        if (res < 0)
+            return res;
     }
 
     if (matroska->num_levels == 2) {
-- 
2.21.0



More information about the ffmpeg-devel mailing list