[MAD Decoder] Don't crash on bad files

The local and seekable file scanner could crash on bad MPEG files if
they failed to decode any frames and broke due to either end of file or
other unrecoverable errors, due to a division by zero error attempting
to calculate the file bitrate. Now correctly return error state if this
occurs, bailing early.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
xcode15
Christopher Snowhill 2022-07-15 22:51:04 -07:00
parent 051b86cbaf
commit 804e7652a8
1 changed files with 5 additions and 0 deletions

View File

@ -406,6 +406,11 @@
}
}
// Don't commit division by zero on bad files
if(stream.next_frame == stream.this_frame) {
return NO;
}
if(!_foundiTunSMPB && !_foundXingHeader && !_foundVBRIHeader) {
// Now do CBR estimation instead of full file scanning
size_t frameCount = (_fileSize - id3_length) / (stream.next_frame - stream.this_frame);