|
| 1 | +From 3660273b4a6b71f9678da744f86a2035fd98fcc2 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Steve Lhomme < [email protected]> |
| 3 | +Date: Fri, 25 Jul 2025 14:37:18 +0200 |
| 4 | +Subject: [PATCH] EbmlMaster: fix leak when reading upper level elements |
| 5 | + |
| 6 | +When an element from an upper level is found we go up the caller chain, |
| 7 | +passing the found element but it was not actually used (added to a list or freed). |
| 8 | + |
| 9 | +This patch allows setting that element as the ElementLevelA found in the loop. |
| 10 | +We skip the call the inDataStream.FindNextElement() to find it. |
| 11 | + |
| 12 | +The new MaxSizeToRead is the size to read in the next inDataStream.FindNextElement() call. |
| 13 | + |
| 14 | +The old MaxSizeToRead <= 0 code seems bogus as it would exit the loop |
| 15 | +to find elements for that EbmlMaster even though there might still be elements to read. |
| 16 | +--- |
| 17 | + src/EbmlMaster.cpp | 5 ++++- |
| 18 | + 1 file changed, 4 insertions(+), 1 deletion(-) |
| 19 | + |
| 20 | +diff --git a/src/EbmlMaster.cpp b/src/EbmlMaster.cpp |
| 21 | +index 071eb5d..465560f 100644 |
| 22 | +--- a/src/EbmlMaster.cpp |
| 23 | ++++ b/src/EbmlMaster.cpp |
| 24 | +@@ -455,9 +455,12 @@ void EbmlMaster::Read(EbmlStream & inDataStream, const EbmlSemanticContext & sCo |
| 25 | + |
| 26 | + if (UpperEltFound > 0) { |
| 27 | + UpperEltFound--; |
| 28 | +- if (UpperEltFound > 0 || MaxSizeToRead <= 0) |
| 29 | ++ if (UpperEltFound > 0) |
| 30 | + goto processCrc; |
| 31 | + ElementLevelA = FoundElt; |
| 32 | ++ if (IsFiniteSize() && ElementLevelA->IsFiniteSize()) { |
| 33 | ++ MaxSizeToRead = GetEndPosition() - ElementLevelA->GetEndPosition(); // even if it's the default value |
| 34 | ++ } |
| 35 | + continue; |
| 36 | + } |
| 37 | + |
| 38 | +-- |
| 39 | +2.45.1.windows.1 |
| 40 | + |
0 commit comments