diff --git a/src/EbmlMaster.cpp b/src/EbmlMaster.cpp index 87ea59f3..49cc3ad7 100644 --- a/src/EbmlMaster.cpp +++ b/src/EbmlMaster.cpp @@ -370,9 +370,12 @@ void EbmlMaster::Read(EbmlStream & inDataStream, const EbmlSemanticContext & sCo if (UpperEltFound > 0) { UpperEltFound--; - if (UpperEltFound > 0 || MaxSizeToRead <= 0) + if (UpperEltFound > 0) goto processCrc; ElementLevelA = FoundElt; + if (IsFiniteSize() && ElementLevelA->IsFiniteSize()) { + MaxSizeToRead = GetEndPosition() - ElementLevelA->GetEndPosition(); // even if it's the default value + } continue; }