Bugzilla – Bug 3153
Incorrect error handling in Audio::FLAC::Header
Last modified: 2008-09-15 14:38:25 UTC
# $Id: Header.pm 4044 2005-08-24 19:17:11Z dsully $ At several places in the constructor method, you check for various errors, warn about them, and return $self anyway. Shouldn't it return undef? This is what seems to be expected by Slim::Formats::FLAC, at least: my $flac = Audio::FLAC::Header->new($file) || do { errorMsg("Couldn't open file: [$file] for reading: $!\n"); return; This does not have the presumably desired effect of failing when "new" fails. I'm a Perl novice; sorry if I've been a blockhead. If it's not a bug, how do I check whether $flac references the header of a valid file or not?
Fixed in change 7077
Still not right, though, I think. This branch returns a hash with more than zero keys, but not a usable one: # make sure dos-type systems can handle it... binmode FILE; $self->{'fileSize'} = -s $file; $self->{'filename'} = $file; $self->{'fileHandle'} = \*FILE; # Initialize FLAC analysis $errflag = $self->_init(); if ($errflag < 0) { warn "[$file] does not appear to be a FLAC file!"; close FILE; undef $self->{'fileHandle'}; return $self; };
Ok - I changed it to return undef - change 7332
This bug fix is now part of a released version, and so has been marked closed. If you are still experiencing this problem, please reopen the bug.