diff --git a/src/EbmlMaster.cpp b/src/EbmlMaster.cpp index 87ea59f3..e24466d1 100644 --- a/src/EbmlMaster.cpp +++ b/src/EbmlMaster.cpp @@ -359,8 +359,13 @@ void EbmlMaster::Read(EbmlStream & inDataStream, const EbmlSemanticContext & sCo if (UpperEltFound) { --UpperEltFound; - if (UpperEltFound > 0 || MaxSizeToRead <= 0) + if (UpperEltFound > 0) goto processCrc; + if (MaxSizeToRead <= 0) { + delete FoundElt; + FoundElt = nullptr; + goto processCrc; + } ElementLevelA = FoundElt; } @@ -372,6 +377,11 @@ void EbmlMaster::Read(EbmlStream & inDataStream, const EbmlSemanticContext & sCo UpperEltFound--; if (UpperEltFound > 0 || MaxSizeToRead <= 0) goto processCrc; + if (MaxSizeToRead <= 0) { + delete FoundElt; + FoundElt = nullptr; + goto processCrc; + } ElementLevelA = FoundElt; continue; }