Fixed a division by zero in mp3 metadata parser.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11003 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
f5520f5cef
commit
7f1346d641
1 changed files with 5 additions and 1 deletions
|
@ -1000,7 +1000,11 @@ static int getsonglength(int fd, struct mp3entry *entry)
|
|||
|
||||
if(filetime == 0)
|
||||
{
|
||||
filetime = (entry->filesize - bytecount) / (info.bitrate / 8);
|
||||
/* Prevent a division by zero */
|
||||
if (info.bitrate < 8)
|
||||
filetime = 0;
|
||||
else
|
||||
filetime = (entry->filesize - bytecount) / (info.bitrate / 8);
|
||||
/* bitrate is in kbps so this delivers milliseconds. Doing bitrate / 8
|
||||
* instead of filesize * 8 is exact, because mpeg audio bitrates are
|
||||
* always multiples of 8, and it avoids overflows. */
|
||||
|
|
Loading…
Reference in a new issue