From 85030995431dae962355c70187bcdaaf1d8515fd Mon Sep 17 00:00:00 2001 From: GarryH Date: Sun, 27 Sep 2026 16:21:09 +1000 Subject: [PATCH] Matroska: Raise the global EBML element bound above real-file needs [5f869755] gave the whole-file element budget the same value as the per-container limit (50000). A real 6,027,872,050-byte .mka requires 99780 elements, so MasterElement::read() returns false and the file is unopenable at every ReadStyle. Raise the global bound to 1000000, leaving the per-level bound untouched. That is ~10x a large real file's requirement and still an order of magnitude below the 'millions of small elements' case the original commit guards against. --- taglib/matroska/ebml/ebmlmasterelement.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/taglib/matroska/ebml/ebmlmasterelement.cpp b/taglib/matroska/ebml/ebmlmasterelement.cpp index 61e18110..e15bc8b4 100644 --- a/taglib/matroska/ebml/ebmlmasterelement.cpp +++ b/taglib/matroska/ebml/ebmlmasterelement.cpp @@ -107,7 +107,10 @@ bool EBML::MasterElement::read(File &file, int depth) bool EBML::MasterElement::read(File &file, int depth, unsigned int &elementCount) { static constexpr int MAX_EBML_DEPTH = 64; - static constexpr int MAX_EBML_ELEMENT_COUNT = 50000; + // Whole-file budget. Must be considerably larger than the per-level limit below: a Matroska's + // Cues/SeekHead index scales with duration, and a real 6.0 GB, 48-minute album measures at 99780 + // elements, so a 50000 whole-file budget rejects ordinary media outright. + static constexpr int MAX_EBML_ELEMENT_COUNT = 1000000; static constexpr int MAX_EBML_ELEMENT_COUNT_PER_LEVEL = 50000; if(depth > MAX_EBML_DEPTH) { debug("EBML: Maximum nesting depth exceeded");