a11y: Avoid out-of-bounds access

Don't use the index before we've checked its good.

Pointed out in https://www.viva64.com/en/b/0793/
This commit is contained in:
Matthias Clasen 2021-02-04 00:34:05 -05:00
parent 0eba833595
commit aa5bd38137

View File

@ -68,10 +68,8 @@ action_handle_method (GtkAtSpiContext *self,
g_variant_get (parameters, "(i)", &idx);
const Action *action = &actions[idx];
if (idx >= 0 && idx < n_actions)
g_dbus_method_invocation_return_value (invocation, g_variant_new ("(s)", action->name));
g_dbus_method_invocation_return_value (invocation, g_variant_new ("(s)", actions[idx].name));
else
g_dbus_method_invocation_return_error (invocation,
G_IO_ERROR,
@ -129,10 +127,8 @@ action_handle_method (GtkAtSpiContext *self,
g_variant_get (parameters, "(i)", &idx);
const Action *action = &actions[idx];
if (idx >= 0 && idx < n_actions)
g_dbus_method_invocation_return_value (invocation, g_variant_new ("(s)", action->keybinding));
g_dbus_method_invocation_return_value (invocation, g_variant_new ("(s)", actions[idx].keybinding));
else
g_dbus_method_invocation_return_error (invocation,
G_IO_ERROR,