diff options
author | Will Thompson <wjt@endlessos.org> | 2023-03-30 11:52:44 +0100 |
---|---|---|
committer | Will Thompson <wjt@endlessos.org> | 2023-03-30 20:56:27 +0100 |
commit | c550106e96d65418f60c25201911651c8bd53e69 (patch) | |
tree | f550a65b6fa78f56e992faa046ce0ae75ab4587d | |
parent | 78fd2a1efbd0c8c8901852a4e8ec46a5d839e83d (diff) | |
download | gnome-initial-setup-c550106e96d65418f60c25201911651c8bd53e69.tar.gz |
keyboard: Don't call g_free on uninitialized variable
if gnome_parse_locale() fails (e.g. because priv->locale is NULL), lang
and country were previously uninitialized. Calling g_free() on an
uninitialized variable is a bad idea.
Fixes https://gitlab.gnome.org/GNOME/gnome-initial-setup/-/issues/187
-rw-r--r-- | gnome-initial-setup/pages/keyboard/cc-input-chooser.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/gnome-initial-setup/pages/keyboard/cc-input-chooser.c b/gnome-initial-setup/pages/keyboard/cc-input-chooser.c index 80f36f2..6b6bd97 100644 --- a/gnome-initial-setup/pages/keyboard/cc-input-chooser.c +++ b/gnome-initial-setup/pages/keyboard/cc-input-chooser.c @@ -407,7 +407,8 @@ get_locale_infos (CcInputChooser *chooser) CcInputChooserPrivate *priv = cc_input_chooser_get_instance_private (chooser); const gchar *type = NULL; const gchar *id = NULL; - gchar *lang, *country; + g_autofree gchar *lang = NULL; + g_autofree gchar *country = NULL; GList *list; if (gnome_get_input_source_from_locale (priv->locale, &type, &id)) { @@ -419,7 +420,7 @@ get_locale_infos (CcInputChooser *chooser) } if (!gnome_parse_locale (priv->locale, &lang, &country, NULL, NULL)) - goto out; + return; list = gnome_xkb_info_get_layouts_for_language (priv->xkb_info, lang); add_rows_to_list (chooser, list, INPUT_SOURCE_TYPE_XKB, id); @@ -436,10 +437,6 @@ get_locale_infos (CcInputChooser *chooser) list = gnome_xkb_info_get_all_layouts (priv->xkb_info); add_rows_to_list (chooser, list, INPUT_SOURCE_TYPE_XKB, id); g_list_free (list); - -out: - g_free (lang); - g_free (country); } static gboolean |