Skip to content

Commit

Permalink
discoverer: Don't crash when running with -v if channel-mask==0 and >…
Browse files Browse the repository at this point in the history
…7 channels

For e.g. 16-channel audio, if the channel mask is 0 (which it usually
is), gst_audio_channel_positions_from_mask would get confused,
ultimately leading into a crash.

https://bugzilla.gnome.org/show_bug.cgi?id=796578
  • Loading branch information
vivia committed Jun 14, 2018
1 parent 1208ef6 commit effd892
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions tools/gst-discoverer.c
Expand Up @@ -157,17 +157,23 @@ format_channel_mask (GstDiscovererAudioInfo * ainfo)
guint channels = gst_discoverer_audio_info_get_channels (ainfo);
GEnumClass *enum_class = g_type_class_ref (GST_TYPE_AUDIO_CHANNEL_POSITION);
guint i;
guint64 channel_mask;

if (channels == 0)
goto done;

gst_audio_channel_positions_from_mask (channels,
gst_discoverer_audio_info_get_channel_mask (ainfo), position);
channel_mask = gst_discoverer_audio_info_get_channel_mask (ainfo);

for (i = 0; i < channels; i++) {
GEnumValue *value = g_enum_get_value (enum_class, position[i]);
my_g_string_append_printf (s, 0, "%s%s", value->value_nick,
i + 1 == channels ? "" : ", ");
if (channel_mask != 0) {
gst_audio_channel_positions_from_mask (channels, channel_mask, position);

for (i = 0; i < channels; i++) {
GEnumValue *value = g_enum_get_value (enum_class, position[i]);
my_g_string_append_printf (s, 0, "%s%s", value->value_nick,
i + 1 == channels ? "" : ", ");
}
} else {
g_string_append (s, "unknown layout");
}

g_type_class_unref (enum_class);
Expand Down

0 comments on commit effd892

Please sign in to comment.