interleave: don't overflow channel map with >64 channels
authorDouglas Bagnall <douglas@halo.gen.nz>
Thu, 23 Mar 2017 10:56:31 +0000 (23:56 +1300)
committerSebastian Dröge <sebastian@centricular.com>
Fri, 31 Mar 2017 11:10:34 +0000 (14:10 +0300)
When there are more than 64 channels, we don't want to exceed the
bounds of the ordering_map buffer, and in these cases we don't want to
rempa at all. Here we avoid doing that.

https://bugzilla.gnome.org/show_bug.cgi?id=780331

gst/interleave/interleave.c

index b2ac76e93970440efb244f56993fb446887377db..cbfff2832aea3ede896276a9df72c1412c38c3a6 100644 (file)
@@ -310,14 +310,15 @@ gst_interleave_set_channel_positions (GstInterleave * self, GstStructure * s)
 {
   guint64 channel_mask = 0;
 
-  if (self->channel_positions != NULL &&
+  if (self->channels <= 64 &&
+      self->channel_positions != NULL &&
       self->channels == self->channel_positions->n_values) {
     if (!gst_interleave_channel_positions_to_mask (self->channel_positions,
             self->default_channels_ordering_map, &channel_mask)) {
       GST_WARNING_OBJECT (self, "Invalid channel positions, using NONE");
       channel_mask = 0;
     }
-  } else {
+  } else if (self->channels <= 64) {
     GST_WARNING_OBJECT (self, "Using NONE channel positions");
   }
   gst_structure_set (s, "channel-mask", GST_TYPE_BITMASK, channel_mask, NULL);
@@ -1228,8 +1229,10 @@ gst_interleave_collected (GstCollectPads * pads, GstInterleave * self)
 
     empty = FALSE;
     channel = GST_INTERLEAVE_PAD_CAST (cdata->pad)->channel;
-    outdata =
-        write_info.data + width * self->default_channels_ordering_map[channel];
+    if (self->channels <= 64) {
+      channel = self->default_channels_ordering_map[channel];
+    }
+    outdata = write_info.data + width * channel;
 
     self->func (outdata, input_info.data, self->channels, nsamples);
     gst_buffer_unmap (inbuf, &input_info);