Subject: | Segfault on eMusic mp3 files with Perl 5.8 |
This file (bt.mp3, a truncated mp3 from eMusic) crashes Audio::Scan with
a segfault on Perl 5.8.* (doesn't do it in Perl 5.10). All eMusic files
will segfault Audio::Scan on Perl 5.8 because of this problem.
The problem is that in id3.c, _id3_parse_v2_frame_data(), this bit of
code:
if ( tmp == end ) {
// Convert raw number to genre string
av_push( genres, newSVpv( _id3_genre_name((char *)sptr), 0 )
);
will pass NULL/0 as the first arg to newSVpv, which according to the XS
docs, will then have a strlen applied to it, causing a segfault.
The best cure is probably to fix it a little above this test:
// v2.4 handles multiple genres using null char separators (or $00
$00 in UTF-16),
// this is handled by _id3_get_utf8_string
read += _id3_get_utf8_string(id3, &value, size - read, encoding);
if (value != NULL && SvPOK(value)) {
sptr = SvPVX(value);
by adding " && SvPVX(value) != 0" to the test. This prevents a bogus
(null) TCON (genre) tag from being created in eMusic mp3 files.