[gnome-initial-setup/wip/pwithnall/misc-fixes: 69/70] language: Fix use-after-free in GisWelcomeWidget
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-initial-setup/wip/pwithnall/misc-fixes: 69/70] language: Fix use-after-free in GisWelcomeWidget
- Date: Fri, 11 Sep 2020 13:29:16 +0000 (UTC)
commit cd4370a8683530e7b5bc184627dab94e56d52878
Author: Philip Withnall <withnall endlessm com>
Date: Fri Sep 11 12:23:38 2020 +0100
language: Fix use-after-free in GisWelcomeWidget
`translation_widgets` was previously indexed by an unowned locale ID
derived from the return value from
`cc_common_language_get_initial_languages()`. However, that return value
was freed when `fill_stack()` exited, freeing all the keys in
`translation_widgets`.
Instead, take a copy.
Signed-off-by: Philip Withnall <withnall endlessm com>
gnome-initial-setup/pages/language/gis-welcome-widget.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/gnome-initial-setup/pages/language/gis-welcome-widget.c
b/gnome-initial-setup/pages/language/gis-welcome-widget.c
index 87f87c59..a1dafc81 100644
--- a/gnome-initial-setup/pages/language/gis-welcome-widget.c
+++ b/gnome-initial-setup/pages/language/gis-welcome-widget.c
@@ -31,7 +31,7 @@
struct _GisWelcomeWidgetPrivate
{
GtkWidget *stack;
- GHashTable *translation_widgets;
+ GHashTable *translation_widgets; /* (element-type owned utf8 unowned GtkWidget) (owned) */
guint timeout_id;
};
@@ -181,7 +181,7 @@ fill_stack (GisWelcomeWidget *widget)
g_hash_table_insert (added_translations, (gpointer) text, label);
}
- g_hash_table_insert (priv->translation_widgets, locale_id, label);
+ g_hash_table_insert (priv->translation_widgets, g_strdup (locale_id), label);
}
}
@@ -223,7 +223,7 @@ gis_welcome_widget_init (GisWelcomeWidget *widget)
{
GisWelcomeWidgetPrivate *priv = gis_welcome_widget_get_instance_private (widget);
- priv->translation_widgets = g_hash_table_new (g_str_hash, g_str_equal);
+ priv->translation_widgets = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
gtk_widget_init_template (GTK_WIDGET (widget));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]