From 62787bcd62865464e8e64093ff5083d03b4e5e28 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Sat, 18 Dec 2004 15:09:27 +0000 Subject: [PATCH] ext/alsa/gstalsasink.c: Fix for integer overflow. Makes #156001 not crash. Probably masks the real bug. Original commit message from CVS: * ext/alsa/gstalsasink.c: (gst_alsa_sink_loop): Fix for integer overflow. Makes #156001 not crash. Probably masks the real bug. --- ChangeLog | 6 ++++++ ext/alsa/gstalsasink.c | 12 +++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index f269d2a718..bc6b63ecad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2004-12-18 Ronald S. Bultje + + * ext/alsa/gstalsasink.c: (gst_alsa_sink_loop): + Fix for integer overflow. Makes #156001 not crash. Probably masks + the real bug. + 2004-12-17 Ronald S. Bultje * gst/ac3parse/gstac3parse.c: (plugin_init): diff --git a/ext/alsa/gstalsasink.c b/ext/alsa/gstalsasink.c index dd25d4a802..a8d4e4c59e 100644 --- a/ext/alsa/gstalsasink.c +++ b/ext/alsa/gstalsasink.c @@ -440,9 +440,15 @@ sink_restart: /* there are empty samples in front of us, fill them with silence */ int samples = MIN (bytes, sample_diff) * (element->numpads == 1 ? this->format->channels : 1); - int size = - samples * snd_pcm_format_physical_width (this->format->format) / - 8; + int width = snd_pcm_format_physical_width (this->format->format); + int size = samples * width / 8; + + if (size / (width / 8) != samples) { + GST_WARNING_OBJECT (this, + "Integer overflow for size=%d/samples=%d - broken stream", + size, samples); + goto no_difference; + } GST_INFO_OBJECT (this, "Allocating %d bytes (%ld samples) now to resync: sample %lu expected, but got %ld", size, MIN (bytes, sample_diff), expected, samplestamp);