summaryrefslogtreecommitdiff
path: root/gst/interleave
diff options
context:
space:
mode:
authorDouglas Bagnall <douglas@halo.gen.nz>2017-03-24 00:11:13 +1300
committerSebastian Dröge <sebastian@centricular.com>2017-03-31 14:10:34 +0300
commita9f26c2a14928cf666bbbea0d0320a7681bdabb3 (patch)
treef6e8205fe492f7d89a816b8f5e5039fb7cbe39a6 /gst/interleave
parentc08d719453e1b6347531fa0d050cb02043d2d6f4 (diff)
downloadgstreamer-plugins-good-a9f26c2a14928cf666bbbea0d0320a7681bdabb3.tar.gz
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
Diffstat (limited to 'gst/interleave')
-rw-r--r--gst/interleave/interleave.c18
-rw-r--r--gst/interleave/interleave.h1
2 files changed, 11 insertions, 8 deletions
diff --git a/gst/interleave/interleave.c b/gst/interleave/interleave.c
index cbfff2832..76b7945bd 100644
--- a/gst/interleave/interleave.c
+++ b/gst/interleave/interleave.c
@@ -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;
diff --git a/gst/interleave/interleave.h b/gst/interleave/interleave.h
index e69936ac9..05ebe3b70 100644
--- a/gst/interleave/interleave.h
+++ b/gst/interleave/interleave.h
@@ -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;