interleave: avoid using uninitialised ordering_map

If self->channel_positions == NULL (which seems unlikely),
self->default_channels_ordering_map will be used unintialised.

We avoid that by keeping track of the channel_mask, which is set when
the ordering map is initialised.

https://bugzilla.gnome.org/show_bug.cgi?id=780331
This commit is contained in:
Douglas Bagnall 2017-03-24 00:11:13 +13:00 committed by Sebastian Dröge
parent c08d719453
commit a9f26c2a14
2 changed files with 11 additions and 8 deletions

View file

@ -308,20 +308,22 @@ gst_interleave_channel_positions_to_mask (GValueArray * positions,
static void static void
gst_interleave_set_channel_positions (GstInterleave * self, GstStructure * s) gst_interleave_set_channel_positions (GstInterleave * self, GstStructure * s)
{ {
guint64 channel_mask = 0;
if (self->channels <= 64 && if (self->channels <= 64 &&
self->channel_positions != NULL && self->channel_positions != NULL &&
self->channels == self->channel_positions->n_values) { self->channels == self->channel_positions->n_values) {
if (!gst_interleave_channel_positions_to_mask (self->channel_positions, if (!gst_interleave_channel_positions_to_mask (self->channel_positions,
self->default_channels_ordering_map, &channel_mask)) { self->default_channels_ordering_map, &self->channel_mask)) {
GST_WARNING_OBJECT (self, "Invalid channel positions, using NONE"); GST_WARNING_OBJECT (self, "Invalid channel positions, using NONE");
channel_mask = 0; self->channel_mask = 0;
}
} else {
self->channel_mask = 0;
if (self->channels <= 64) {
GST_WARNING_OBJECT (self, "Using NONE channel positions");
} }
} 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); gst_structure_set (s, "channel-mask", GST_TYPE_BITMASK, self->channel_mask,
NULL);
} }
static void static void
@ -1229,7 +1231,7 @@ gst_interleave_collected (GstCollectPads * pads, GstInterleave * self)
empty = FALSE; empty = FALSE;
channel = GST_INTERLEAVE_PAD_CAST (cdata->pad)->channel; channel = GST_INTERLEAVE_PAD_CAST (cdata->pad)->channel;
if (self->channels <= 64) { if (self->channels <= 64 && self->channel_mask) {
channel = self->default_channels_ordering_map[channel]; channel = self->default_channels_ordering_map[channel];
} }
outdata = write_info.data + width * channel; outdata = write_info.data + width * channel;

View file

@ -61,6 +61,7 @@ struct _GstInterleave
gboolean channel_positions_from_input; gboolean channel_positions_from_input;
gint default_channels_ordering_map[64]; gint default_channels_ordering_map[64];
guint64 channel_mask;
GstCaps *sinkcaps; GstCaps *sinkcaps;
gint configured_sinkpads_counter; gint configured_sinkpads_counter;