mirror of
https://github.com/Rockbox/rockbox.git
synced 2026-10-10 08:03:04 -04:00
flac: don't divide by zero when STREAMINFO has no sample count
A total sample count of 0 means unknown. It made the track length 0 and the bitrate estimate in flac_init() divided by it, crashing the codec (FLAC decoder testbench file 45). Report a bitrate of 0 in that case. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
a81fd7b77f
commit
04ecb3c645
1 changed files with 3 additions and 2 deletions
|
|
@ -209,8 +209,9 @@ static bool flac_init(FLACContext* fc, int first_frame_offset)
|
|||
}
|
||||
|
||||
if (found_streaminfo) {
|
||||
fc->bitrate = ((int64_t) (fc->filesize-fc->metadatalength) * 8)
|
||||
/ fc->length;
|
||||
/* length is 0 when STREAMINFO has no total sample count */
|
||||
fc->bitrate = fc->length ? ((int64_t) (fc->filesize-fc->metadatalength) * 8)
|
||||
/ fc->length : 0;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue