fontchooserwidget: Avoid a crash

languages may be NULL, we need to be more careful here.
This commit is contained in:
Matthias Clasen 2021-12-31 09:49:40 -05:00
parent 536b05e35b
commit e12ef76de5

View File

@ -603,19 +603,20 @@ maybe_update_preview_text (GtkFontChooserWidget *self,
/* Otherwise, we make a list of representative languages */ /* Otherwise, we make a list of representative languages */
langs = g_hash_table_new (NULL, NULL); langs = g_hash_table_new (NULL, NULL);
for (i = 0; languages[i]; i++) if (languages)
{ for (i = 0; languages[i]; i++)
const PangoScript *scripts; {
int num, j; const PangoScript *scripts;
int num, j;
scripts = pango_language_get_scripts (languages[i], &num); scripts = pango_language_get_scripts (languages[i], &num);
for (j = 0; j < num; j++) for (j = 0; j < num; j++)
{ {
lang = pango_script_get_sample_language (scripts[j]); lang = pango_script_get_sample_language (scripts[j]);
if (lang) if (lang)
g_hash_table_add (langs, lang); g_hash_table_add (langs, lang);
} }
} }
/* ... and compare it to the users default and preferred languages */ /* ... and compare it to the users default and preferred languages */
if (g_hash_table_contains (langs, default_lang) || if (g_hash_table_contains (langs, default_lang) ||