diff options
author | Douglas Bagnall <douglas@halo.gen.nz> | 2017-03-24 00:11:13 +1300 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2017-03-31 14:10:34 +0300 |
commit | a9f26c2a14928cf666bbbea0d0320a7681bdabb3 (patch) | |
tree | f6e8205fe492f7d89a816b8f5e5039fb7cbe39a6 /gst/interleave | |
parent | c08d719453e1b6347531fa0d050cb02043d2d6f4 (diff) | |
download | gstreamer-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.c | 18 | ||||
-rw-r--r-- | gst/interleave/interleave.h | 1 |
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; |