audio: Fix overread in channel positions
authorEdward Hervey <edward.hervey@collabora.co.uk>
Wed, 5 Oct 2011 09:51:07 +0000 (11:51 +0200)
committerEdward Hervey <edward.hervey@collabora.co.uk>
Wed, 5 Oct 2011 09:51:07 +0000 (11:51 +0200)
The array we're writing to is limited to 64 ... but the amount of
input positions might be lower than 64. Therefore use MIN and not
MAX to know how many values to read from the array.

gst-libs/gst/audio/audio.c

index 49a4878..042364f 100644 (file)
@@ -346,7 +346,8 @@ gst_audio_info_from_caps (GstAudioInfo * info, const GstCaps * caps)
 
   pos_val_arr = gst_structure_get_value (str, "channel-positions");
   if (pos_val_arr) {
-    guint max_pos = MAX (channels, 64);
+    guint max_pos = MIN (channels, 64);
+
     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);