Commit a9f26c2a authored by Douglas Bagnall's avatar Douglas Bagnall Committed by Sebastian Dröge

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
parent c08d7194
......@@ -308,20 +308,22 @@ gst_interleave_channel_positions_to_mask (GValueArray * positions,
static void
gst_interleave_set_channel_positions (GstInterleave * self, GstStructure * s)
{
guint64 channel_mask = 0;
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)) {
self->default_channels_ordering_map, &self->channel_mask)) {
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
......@@ -1229,7 +1231,7 @@ gst_interleave_collected (GstCollectPads * pads, GstInterleave * self)
empty = FALSE;
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];
}
outdata = write_info.data + width * channel;
......
......@@ -61,6 +61,7 @@ struct _GstInterleave
gboolean channel_positions_from_input;
gint default_channels_ordering_map[64];
guint64 channel_mask;
GstCaps *sinkcaps;
gint configured_sinkpads_counter;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment