if (pmp3->song_length < 1000), then you get
division by zero. The diff below illustrates what
needs to be fixed, although the proper fix might
be different:
> diff -U 12 mp3-scanner.c.orig mp3-scanner.c
— mp3-scanner.c.orig Sun Oct 15 20:48:55 2006
+++ mp3-scanner.c Sun Oct 15 20:53:17 2006
@@ -1202,27 +1202,35 @@
} else {
DPRINTF(E_DBG,L_SCAN, “Could not find ‘mp4a’ atom to determine sample rate.n”);
}
/* Fallback if we can’t find the info in the atoms. */
if (pmp3->bitrate == 0) {
/* calculate bitrate from song length… Kinda cheesy */
DPRINTF(E_DBG,L_SCAN, “Could not find ‘esds’ atom. Calculating bit rate.n”);
atom_offset=aac_drilltoatom(infile,”mdat”,&atom_length);
+#if 0
+ /* original code */
if ((atom_offset != -1) && (pmp3->song_length)) {
pmp3->bitrate = atom_length / ((pmp3->song_length / 1000) * 128);
}
+#elif 1
+ /* avoid division by zero when (song_length < 1000) */
+ if ((atom_offset != -1) && (pmp3->song_length >= 1000)) {
+ pmp3->bitrate = atom_length / ((pmp3->song_length / 1000) * 128);
+ }
+#endif
}
fclose(infile);
return 0;
}