diff mbox

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

Message ID 20190905201609.998-1-andreas.rheinhardt@gmail.com
State New
Headers show

Commit Message

Andreas Rheinhardt Sept. 5, 2019, 8:16 p.m. UTC
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@gmail.com>
 libavformat/matroskadec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox


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) {