From b8219faa903802fa1f636269a53f9ee60f4bd958 Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Wed, 5 Oct 2011 11:57:54 +0200 Subject: [PATCH] audio: Make sure 'channels' and 'channel-positions' are coherent If channel-positions are present, check they match the reported 'channels' value. --- gst-libs/gst/audio/audio.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/gst-libs/gst/audio/audio.c b/gst-libs/gst/audio/audio.c index 042364f160..d24023f932 100644 --- a/gst-libs/gst/audio/audio.c +++ b/gst-libs/gst/audio/audio.c @@ -345,9 +345,13 @@ gst_audio_info_from_caps (GstAudioInfo * info, const GstCaps * caps) gst_audio_info_set_format (info, format, rate, channels); pos_val_arr = gst_structure_get_value (str, "channel-positions"); + if (pos_val_arr) { guint max_pos = MIN (channels, 64); + if (channels != gst_value_array_get_size (pos_val_arr)) + goto incoherent_channels; + for (i = 0; i < max_pos; i++) { pos_val_entry = gst_value_array_get_value (pos_val_arr, i); info->position[i] = g_value_get_enum (pos_val_entry); @@ -385,6 +389,13 @@ no_channels: GST_ERROR ("no channels property given"); return FALSE; } + +incoherent_channels: + { + GST_ERROR ("There should be %d channels positions, but %d are present", + channels, gst_value_array_get_size (pos_val_arr)); + return FALSE; + } } /**