Skip to content

Commit 21d46df

Browse files
authored
Behave if child atom is empty (#170)
Credit: https://github.com/ta264 Lidarr#5
1 parent f4c076e commit 21d46df

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/TaglibSharp/Mpeg4/Box.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,9 @@ protected IEnumerable<Box> LoadChildren (TagLib.File file)
456456
header.Box = this;
457457
while (position < end) {
458458
Box child = BoxFactory.CreateBox (file, position, header, Handler, children.Count);
459+
if (child.Size == 0)
460+
break;
461+
459462
children.Add (child);
460463
position += child.Size;
461464
}

src/TaglibSharp/Mpeg4/Boxes/UnknownBox.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,12 @@ public class UnknownBox : Box
6464
/// <exception cref="ArgumentNullException">
6565
/// <paramref name="file" /> is <see langword="null" />.
6666
/// </exception>
67-
public UnknownBox (BoxHeader header, TagLib.File file, IsoHandlerBox handler)
68-
: base (header, handler)
67+
public UnknownBox (BoxHeader header, TagLib.File file, IsoHandlerBox handler) : base (header, handler)
6968
{
7069
if (file == null)
7170
throw new ArgumentNullException (nameof (file));
7271

73-
data = LoadData (file);
72+
data = file.ReadBlock (DataSize > 0 ? DataSize : 0);
7473
}
7574

7675
#endregion

0 commit comments

Comments
 (0)