Subject: | _write_PP generates corrupt flac file |
Using the _write_PP() method (or the write() method without libFLAC
installed) results in a corrupt FLAC file.
Trying to read this file using metaflac --list write.flac gives:
data/write.flac: ERROR: reading metadata, status =
"FLAC__METADATA_CHAIN_STATUS_MEMORY_ALLOCATION_ERROR"
The pure perl _write_PP() method is not exercised by the existing
write.t test. I attach a patch to change this.
After patching the test, this issue is spotted during the 'make test'
stage, along with another bug in the _parseVorbisComments method, filed
separately as bug #42305.
I'm using:
Audio::FLAC::Header v2.3
perl v5.8.8
Linux version 2.6.27-gentoo-r7 on x86
Subject: | test_write_PP.diff |
--- ../write.t.original 2009-01-11 17:05:20.000000000 +0000
+++ ./t/write.t 2009-01-11 17:09:03.000000000 +0000
@@ -11,8 +11,22 @@
#########################
{
- # Be sure to test both code paths.
- for my $constructor (qw(_new_PP _new_XS)) {
+ # Always test pure perl
+ my @modes = ('PP');
+
+ # Only test XS if built
+ SKIP: {
+ eval { Audio::FLAC::Header->_new_XS(catdir('data', 'empty.flac')) };
+ skip "Not built with XS", 3 if $@;
+
+ push @modes, 'XS';
+ }
+
+ # Be sure to test both code paths.
+ for my $mode (@modes) {
+
+ my $constructor = "_new_$mode";
+ my $write_method = "_write_$mode";
my $empty = catdir('data', 'empty.flac');
my $write = catdir('data', 'write.flac');
@@ -27,7 +41,7 @@
$tags->{'ALBUM'} = 'FOO';
- ok($flac->write, "Wrote out tags");
+ ok($flac->$write_method, "Wrote out tags");
undef $flac;