summaryrefslogtreecommitdiff
path: root/libavformat/matroskadec.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2019-05-17 00:30:21 +0200
committerJames Almer <jamrial@gmail.com>2019-07-16 16:18:10 -0300
commit806ac7da6927c1a9db2d6bc7af272733078964a0 (patch)
tree211684c9f7bfa53d350ce7355f26a6e7f09000cf /libavformat/matroskadec.c
parent730ac1ae803925777702eeaef4d1b8b796126e8f (diff)
avformat/matroskadec: Improve check for level 1 duplicates
If a file uses unknown-length level 1 elements besides clusters and such elements are after the first cluster, then these elements will usually be parsed twice: Once during parsing of the file header and once when reading the file reaches the position where these elements are located. The second time the element is parsed leads to a "Duplicate element" error message. Known-length elements are not affected by this as they are skipped except during parsing the header. This commit fixes this by explicitly adding a check for whether the position of the element to be parsed is the same as the position of the already known level 1 element. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavformat/matroskadec.c')
-rw-r--r--libavformat/matroskadec.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 3abdf01374..b97189e674 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -1390,7 +1390,10 @@ static int ebml_parse(MatroskaDemuxContext *matroska,
matroska->cues_parsing_deferred = 0;
if (syntax->type == EBML_LEVEL1 &&
(level1_elem = matroska_find_level1_elem(matroska, syntax->id))) {
- if (level1_elem->parsed)
+ if (!level1_elem->pos) {
+ // Zero is not a valid position for a level 1 element.
+ level1_elem->pos = pos;
+ } else if (level1_elem->pos != pos)
av_log(matroska->ctx, AV_LOG_ERROR, "Duplicate element\n");
level1_elem->parsed = 1;
}