From 21d46dfe616a2293c549f94ba4c2d6ba53bea131 Mon Sep 17 00:00:00 2001 From: Stephen Shaw Date: Mon, 22 Jul 2019 17:11:34 -0600 Subject: [PATCH] Behave if child atom is empty (#170) Credit: https://github.com/ta264 https://github.com/lidarr/taglib-sharp/pull/5 --- src/TaglibSharp/Mpeg4/Box.cs | 3 +++ src/TaglibSharp/Mpeg4/Boxes/UnknownBox.cs | 5 ++--- 2 files changed, 5 insertions(+), 3 deletions(-) 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