Issue #9880: Crash on startup (invalid accelerator string '<Primary>VoidSymbol').

GTK docs is pretty clear:

> It is a programmer error to pass an invalid accelerator string. If you are
> unsure, check it with gtk_accelerator_parse() first.

So now we verify validity of accelerator strings before using shortcuts from
config files (which can be consider "human input" as the file can be modified).
This commit is contained in:
Jehan 2023-09-25 11:49:28 +02:00
parent 847afa116f
commit 823adbe9f9
1 changed files with 13 additions and 2 deletions

View File

@ -269,9 +269,20 @@ shortcuts_action_deserialize (GScanner *scanner,
builder = g_strv_builder_new ();
while (gimp_scanner_parse_string (scanner, &accel))
{
gchar **dup_actions;
gboolean add_accel = TRUE;
gchar **dup_actions;
gboolean add_accel = TRUE;
guint accelerator_key = 0;
GdkModifierType accelerator_mods = 0;
gtk_accelerator_parse (accel, &accelerator_key, &accelerator_mods);
if (accelerator_key == 0 && accelerator_mods == 0)
{
g_printerr ("INFO: invalid accelerator '%s' on '%s'.\n"
" Removing this accelerator.\n",
accel, action_name);
g_free (accel);
continue;
}
dup_actions = gtk_application_get_actions_for_accel (application, accel);
for (gint i = 0; dup_actions[i] != NULL; i++)