creeperyang / id3-parser

A pure JavaScript id3 tag parser.
54 stars 13 forks source link

calcFrameSize returning NaN #1

Closed patrickjennings closed 9 years ago

patrickjennings commented 9 years ago

Inside of parseV2Frames, I noticed that calcFrameSize would sometimes return NaN or a really large number and cause issues inside of the loop. I fixed the issue by changing to the following:

if(isNaN(size) || size === 0 || size > buffer.length - position - 10) { break; }

Let me know what you think.

creeperyang commented 9 years ago

@patrickjennings I'll check it tonight. Would you like to use test example to show details, or make a pull request to contribute?

patrickjennings commented 9 years ago

Perfect. I will send two files via email to you which I have found cause this issue.

creeperyang commented 9 years ago

Fixed the bug. I test your two files again, 11. The Herbaliser - Repetitive Loop (Reloop).mp3 will be parsed successfully. But 01 Shapes of Things 1.mp3, its tag version is id3v2.2, which is not supported yet.

{
    version: {
        v2: {
            major: 2,
            minor: 2,
            revision: 0
        }
    },
    flags: {
        unsync: 0,
        xheader: 0,
        experimental: 0
    }
}