NCrusher74 / SwiftTagger

A simple library for reading and editing metadata and chapters of Mp4 and Mp3 audio files
Apache License 2.0
9 stars 4 forks source link

Specific artwork causes app to crash on magicNumberData #4

Closed Dreeke closed 2 years ago

Dreeke commented 3 years ago

Hi @NCrusher74,

I love this package! I'm running into the following issue though:

When I import a specific mp3 file my app crashes on Swifttagger in ImageFormat.swift line 93.

The mp3 is a downloaded podcast: https://chtbl.com/track/91854/traffic.megaphone.fm/LAV1308607275.mp3?updated=1626721464

The culprit appears to be the artwork.

It crashes on the line 93 that is linked to .bmp even though the actual image appears to be a .tiff format.

 } else if magicNumberData[0..<2] == Data([0x42, 0x4D]) {
            self = .bmp
        } else if magicNumberData[0..<3] == Data([0x49, 0x20, 0x49]) {
            self = .tiff

A screenshot is attached with the hex codes for the beginning of the file.

Screenshot 2021-08-24 at 12 19 02

When I remove the artwork from the file it imports the mp3 into my app without any issues.

Dreeke

NCrusher74 commented 2 years ago

Hi @Dreeke . I apologize for the delay in responding, life has prevented me from being able to work on this recently.

The problem was actually in SwiftTaggerID3, so update your dependencies to 1.8.1 and let me know if that solves the problem.

Dreeke commented 2 years ago

Perfect! That solves the problem. Thank you for the fix @NCrusher74!