Subject: | Segmentation fault when reading some FLAC files |
Hi, as reported by a Debian user in
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=479580,
Audio-FLAC-Header triggers a segfault when opening a flac file that has
no VENDOR tag.
The reporter correctly traced back the problem to an unchecked call to
newSVpv, passing a NULL pointer when there's no VENDOR tag. He also
provided a patch, included below.
It should be noted that this problem disappears with perl 5.10, as
newSVpv now checks the pointer before calling strlen, but I think that
this should be fixed nevertheless.
Thanks for your work, Tincho.
The patch:
Index: libaudio-flac-header-perl-2.0/Header.xs
===================================================================
--- libaudio-flac-header-perl-2.0.orig/Header.xs 2008-05-05
07:49:50.000000000 -0700
+++ libaudio-flac-header-perl-2.0/Header.xs 2008-05-05
07:50:39.000000000 -0700
@@ -155,7 +155,8 @@
AV *rawTagArray = newAV();
HV *tags = newHV();
- my_hv_store(tags, "VENDOR",
newSVpv((char*)block->data.vorbis_comment.vendor_string.entry, 0));
+ if (block->data.vorbis_comment.vendor_string.entry)
+ my_hv_store(tags, "VENDOR",
newSVpv((char*)block->data.vorbis_comment.vendor_string.entry, 0));
for (i = 0; i < block->data.vorbis_comment.num_comments; i++) {