Commit 806ac7da authored by Andreas Rheinhardt's avatar Andreas Rheinhardt Committed by James Almer

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: 's avatarAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
parent 730ac1ae
...@@ -1390,7 +1390,10 @@ static int ebml_parse(MatroskaDemuxContext *matroska, ...@@ -1390,7 +1390,10 @@ static int ebml_parse(MatroskaDemuxContext *matroska,
matroska->cues_parsing_deferred = 0; matroska->cues_parsing_deferred = 0;
if (syntax->type == EBML_LEVEL1 && if (syntax->type == EBML_LEVEL1 &&
(level1_elem = matroska_find_level1_elem(matroska, syntax->id))) { (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"); av_log(matroska->ctx, AV_LOG_ERROR, "Duplicate element\n");
level1_elem->parsed = 1; level1_elem->parsed = 1;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment