[MPlayer-advusers] PATCH: FPE in demux_audio.c
Andrew A. Gill
superluser at frontiernet.net
Thu Jul 28 02:38:57 CEST 2005
--- BUG DESCRIPTION ---
There is a division by zero problem (two, actually) in
main/libmpdemux/demux_audio.c. When playing MP3 or FLAC, it
attempts to divide by sh_audio->i_bps which is unset.
This doesn't happen when using a container, so presumably bps is
defined by the container. For some reason, this doesn't cause
FPE on IEEE 754-conformant processors (e.g. x86, unlike DEC
Alpha).
--- BUG DESCRIPTION ---
--- RESOLUTION ---
A patch is attached.
The patch resolves the issue quite well by adding a switch-case
statement to the affected lines. It is, however, evaluated
every time that the audio buffer is filled, so more efficient
solutions may be preferable.
Also, I suggest that the code be checked for arithmetic traps.
(if there's a test suite, I'd be happy to do it)
--- RESOLUTION ---
--
|Andrew A. Gill |I posted to Silent-Tristero and|
|<superluser at frontiernet.net> |all I got was this stupid sig! |
|alt.tv.simpsons CBG-FAQ author | |
| (Report all obscene mail to Le Maitre Pots)|
|Yet: <http://www.needsfoodbadly.com> Temporary sig: --
Yay advusers!
-------------- next part --------------
--- main/libmpdemux/demux_audio.c 2005-04-18 16:51:34.000000000 -0400
+++ main/libmpdemux/demux_audio.c 2005-07-27 20:03:00.000000000 -0400
@@ -415,7 +415,15 @@
l = 65535;
dp = new_demux_packet(l);
l = stream_read(s,dp->buffer,l);
- priv->last_pts = priv->last_pts < 0 ? 0 : priv->last_pts + l/(float)sh_audio->i_bps;
+ switch (sh_audio->i_bps)
+ {
+ case 0:
+ priv->last_pts = 0;
+ break;
+ default:
+ priv->last_pts = priv->last_pts < 0 ? 0 : priv->last_pts + l/(float)sh_audio->i_bps;
+ break;
+ }
break;
}
default:
@@ -424,8 +432,16 @@
}
resize_demux_packet(dp, l);
- ds->pts = priv->last_pts - (ds_tell_pts(demux->audio) -
- sh_audio->a_in_buffer_len)/(float)sh_audio->i_bps;
+ switch (sh_audio->i_bps)
+ {
+ case 0:
+ ds->pts = 0;
+ break;
+ default:
+ ds->pts = priv->last_pts - (ds_tell_pts(demux->audio) -
+ sh_audio->a_in_buffer_len)/(float)sh_audio->i_bps;
+ break;
+ }
ds_add_packet(ds, dp);
return 1;
}
More information about the MPlayer-advusers
mailing list