You are here: Home » Topic » SIGFPE in mp3-scanner.c, version 0.2.4

SIGFPE in mp3-scanner.c, version 0.2.4

This topic contains 1 reply, has 1 voice, and was last updated by  rpedde 11 years ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #682

    arvzb

    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;
    }

    #6828

    rpedde
    Participant

    @arvzb wrote:

    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:

    That was still hanging around in nightlies, but has been fixed. Nice catch. Thanks.

    — Ron

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.