]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/matroskadec.c
Merge commit '4fd7e63c87226584e60200b82630a6057c0a6663'
[ffmpeg] / libavformat / matroskadec.c
index 3b45c3b04e904108e05874776416c4fc055d5bc1..9c476c12b28269eeb7327e05641da0d567111a63 100644 (file)
 
 #include <inttypes.h>
 #include <stdio.h>
-#if CONFIG_BZLIB
-#include <bzlib.h>
-#endif
-#if CONFIG_ZLIB
-#include <zlib.h>
-#endif
 
 #include "libavutil/avstring.h"
 #include "libavutil/base64.h"
 #include "riff.h"
 #include "rmsipr.h"
 
+#if CONFIG_BZLIB
+#include <bzlib.h>
+#endif
+#if CONFIG_ZLIB
+#include <zlib.h>
+#endif
+
 typedef enum {
     EBML_NONE,
     EBML_UINT,
@@ -1413,13 +1414,17 @@ static void matroska_execute_seekhead(MatroskaDemuxContext *matroska)
     EbmlList *seekhead_list = &matroska->seekhead;
     int64_t before_pos = avio_tell(matroska->ctx->pb);
     int i;
+    int nb_elem;
 
     // we should not do any seeking in the streaming case
     if (!matroska->ctx->pb->seekable ||
         (matroska->ctx->flags & AVFMT_FLAG_IGNIDX))
         return;
 
-    for (i = 0; i < seekhead_list->nb_elem; i++) {
+    // do not read entries that are added while parsing seekhead entries
+    nb_elem = seekhead_list->nb_elem;
+
+    for (i = 0; i < nb_elem; i++) {
         MatroskaSeekhead *seekhead = seekhead_list->elem;
         if (seekhead[i].pos <= before_pos)
             continue;
@@ -1436,6 +1441,9 @@ static void matroska_execute_seekhead(MatroskaDemuxContext *matroska)
             break;
         }
     }
+    if (nb_elem != seekhead_list->nb_elem) {
+        avpriv_request_sample(matroska->ctx, "recursive SeekHead elements");
+    }
 }
 
 static void matroska_add_index_entries(MatroskaDemuxContext *matroska)