mirror of
https://github.com/taglib/taglib.git
synced 2026-07-11 05:41:22 -04:00
[Matroska] Skip invalid Elements
Some files might have some invalid elements, but most elements might be correct. In this case it would be useful to still parse the correct elements and skip the invalid ones. When an invalid element is encountered we can set the seek position in the file to the (known) end of that Element. Then further elements can be read starting from that position. Signed-off-by: Anthony Brandon <anthony.brandon@gmail.com>
This commit is contained in:
committed by
Urs Fleisch
parent
13239fde26
commit
e0d24f7fa7
@@ -109,16 +109,24 @@ bool EBML::MasterElement::read(File &file, int depth)
|
||||
std::unique_ptr<Element> element;
|
||||
while((element = findNextElement(file, maxOffset))) {
|
||||
if(auto master = dynamic_cast<MasterElement *>(element.get())) {
|
||||
if(!master->read(file, depth + 1))
|
||||
return false;
|
||||
if(!master->read(file, depth + 1)) {
|
||||
debug("EBML: Invalid MasterElement");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(!element->read(file))
|
||||
return false;
|
||||
if(!element->read(file)) {
|
||||
debug("EBML: Invalid Element");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
elements.push_back(std::move(element));
|
||||
}
|
||||
return file.tell() == maxOffset;
|
||||
if(file.tell() == maxOffset) {
|
||||
return true;
|
||||
}
|
||||
file.seek(maxOffset);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool EBML::MasterElement::read(File &file)
|
||||
|
||||
Reference in New Issue
Block a user