diff --git a/src/EbmlElement.cpp b/src/EbmlElement.cpp index b2d720c5..8f5219fa 100644 --- a/src/EbmlElement.cpp +++ b/src/EbmlElement.cpp @@ -324,6 +324,7 @@ EbmlElement * EbmlElement::FindNextElement(IOCallback & DataStream, const EbmlSe ///< \todo continue is misplaced if (Result != nullptr) { if (AllowDummyElt || !Result->IsDummy()) { + assert(Result->ElementSpec().IsSizeValid(SizeFound)); Result->SetSizeLength(_SizeLength); Result->Size = SizeFound; @@ -332,7 +333,7 @@ EbmlElement * EbmlElement::FindNextElement(IOCallback & DataStream, const EbmlSe // 0 : child // 1 : same level // + : further parent - if (Result->ElementSpec().IsSizeValid(SizeFound) && (SizeFound == SizeUnknown || UpperLevel > 0 || MaxDataSize == 0 || + if ((SizeFound == SizeUnknown || UpperLevel > 0 || MaxDataSize == 0 || MaxDataSize >= (IdStart + PossibleID_Length + _SizeLength + SizeFound))) { Result->ElementPosition = ParseStart + IdStart; Result->SizePosition = Result->ElementPosition + PossibleID_Length;