From e12ef76de532d4cf652fe50383bc5bb378866295 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 31 Dec 2021 09:49:40 -0500 Subject: [PATCH] fontchooserwidget: Avoid a crash languages may be NULL, we need to be more careful here. --- gtk/gtkfontchooserwidget.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/gtk/gtkfontchooserwidget.c b/gtk/gtkfontchooserwidget.c index e16de437c4..27608eb16f 100644 --- a/gtk/gtkfontchooserwidget.c +++ b/gtk/gtkfontchooserwidget.c @@ -603,19 +603,20 @@ maybe_update_preview_text (GtkFontChooserWidget *self, /* Otherwise, we make a list of representative languages */ langs = g_hash_table_new (NULL, NULL); - for (i = 0; languages[i]; i++) - { - const PangoScript *scripts; - int num, j; + if (languages) + for (i = 0; languages[i]; i++) + { + const PangoScript *scripts; + int num, j; - scripts = pango_language_get_scripts (languages[i], &num); - for (j = 0; j < num; j++) - { - lang = pango_script_get_sample_language (scripts[j]); - if (lang) - g_hash_table_add (langs, lang); - } - } + scripts = pango_language_get_scripts (languages[i], &num); + for (j = 0; j < num; j++) + { + lang = pango_script_get_sample_language (scripts[j]); + if (lang) + g_hash_table_add (langs, lang); + } + } /* ... and compare it to the users default and preferred languages */ if (g_hash_table_contains (langs, default_lang) ||