diff --git a/src/TaglibSharp/Mpeg4/Box.cs b/src/TaglibSharp/Mpeg4/Box.cs index 3ff89fcf..3619a8e7 100644 --- a/src/TaglibSharp/Mpeg4/Box.cs +++ b/src/TaglibSharp/Mpeg4/Box.cs @@ -456,6 +456,9 @@ protected IEnumerable LoadChildren (TagLib.File file) header.Box = this; while (position < end) { Box child = BoxFactory.CreateBox (file, position, header, Handler, children.Count); + if (child.Size == 0) + break; + children.Add (child); position += child.Size; } diff --git a/src/TaglibSharp/Mpeg4/Boxes/UnknownBox.cs b/src/TaglibSharp/Mpeg4/Boxes/UnknownBox.cs index 67589f10..ef0262f8 100644 --- a/src/TaglibSharp/Mpeg4/Boxes/UnknownBox.cs +++ b/src/TaglibSharp/Mpeg4/Boxes/UnknownBox.cs @@ -64,13 +64,12 @@ public class UnknownBox : Box /// /// is . /// - public UnknownBox (BoxHeader header, TagLib.File file, IsoHandlerBox handler) - : base (header, handler) + public UnknownBox (BoxHeader header, TagLib.File file, IsoHandlerBox handler) : base (header, handler) { if (file == null) throw new ArgumentNullException (nameof (file)); - data = LoadData (file); + data = file.ReadBlock (DataSize > 0 ? DataSize : 0); } #endregion