ext/alsa/gstalsasink.c: Fix for integer overflow. Makes #156001 not crash. Probably...
authorRonald S. Bultje <rbultje@ronald.bitfreak.net>
Sat, 18 Dec 2004 15:09:27 +0000 (15:09 +0000)
committerRonald S. Bultje <rbultje@ronald.bitfreak.net>
Sat, 18 Dec 2004 15:09:27 +0000 (15:09 +0000)
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
ext/alsa/gstalsasink.c

index f269d2a..bc6b63e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2004-12-18  Ronald S. Bultje  <rbultje@ronald.bitfreak.net>
+
+       * 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  <rbultje@ronald.bitfreak.net>
 
        * gst/ac3parse/gstac3parse.c: (plugin_init):
index dd25d4a..a8d4e4c 100644 (file)
@@ -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);