summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-01-13 18:43:59 +0100
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-01-13 18:43:59 +0100
commitbdfa962b2a5ea20b934dbe030b7fe23832f6ee7c (patch)
treeba2bd9dbda5e46af03b8f4ee700206e25d6c8bb3 /plugins
parentd23810081f45762abbf85887b2b3021dc2d842dd (diff)
arithmetic exception fix in mpgmad plugin
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mpgmad/mpgmad.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/plugins/mpgmad/mpgmad.c b/plugins/mpgmad/mpgmad.c
index 0dec44d0..55bced8f 100644
--- a/plugins/mpgmad/mpgmad.c
+++ b/plugins/mpgmad/mpgmad.c
@@ -28,6 +28,9 @@
#define min(x,y) ((x)<(y)?(x):(y))
#define max(x,y) ((x)>(y)?(x):(y))
+#define likely(x) __builtin_expect((x),1)
+#define unlikely(x) __builtin_expect((x),0)
+
static DB_decoder_t plugin;
static DB_functions_t *deadbeef;
@@ -659,6 +662,10 @@ MadFixedToFloat (mad_fixed_t Fixed) {
static int
cmp3_decode_cut (int framesize) {
if (buffer.duration >= 0) {
+ if (unlikely (!buffer.channels || buffer.channels > 2)) {
+ trace ("mpgmad: got frame with invalid number of channels (%d)\n", buffer.channels);
+ return 1;
+ }
if (buffer.currentsample + buffer.readsize / (framesize * buffer.channels) > buffer.endsample) {
int sz = (buffer.endsample - buffer.currentsample + 1) * framesize * buffer.channels;
trace ("size truncated to %d bytes, cursample=%d, endsample=%d, totalsamples=%d\n", buffer.readsize, buffer.currentsample, buffer.endsample, buffer.totalsamples);