Skip to content

Commit

Permalink
Behave if child atom is empty (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
decriptor authored Jul 22, 2019
1 parent f4c076e commit 21d46df
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/TaglibSharp/Mpeg4/Box.cs
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,9 @@ protected IEnumerable<Box> LoadChildren (TagLib.File file)
header.Box = this;
while (position < end) {
Box child = BoxFactory.CreateBox (file, position, header, Handler, children.Count);
if (child.Size == 0)

This comment has been minimized.

Copy link
@LeadAssimilator

LeadAssimilator Apr 8, 2024

Why? What if we want empty boxes?

break;

children.Add (child);
position += child.Size;
}
Expand Down
5 changes: 2 additions & 3 deletions src/TaglibSharp/Mpeg4/Boxes/UnknownBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,12 @@ public class UnknownBox : Box
/// <exception cref="ArgumentNullException">
/// <paramref name="file" /> is <see langword="null" />.
/// </exception>
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);

This comment has been minimized.

Copy link
@LeadAssimilator

LeadAssimilator Apr 8, 2024

This change causes garbage data fields for unknown boxes and should be reverted. BoxHeader reads more than it should and relies on LoadData to seek to the proper place to correct it. But since that is no longer called, the file position remains too far forward and the read data winds up being offset.

If sanity checking the data size to prevent an exception from ReadBlock is desired, that should be done within LoadData or the exception caught again within LoadData. Also the null check here might be redundant since LoadData does it.

}

#endregion
Expand Down

0 comments on commit 21d46df

Please sign in to comment.