summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2020-09-08 16:49:43 -0400
committerMatthias Clasen <mclasen@redhat.com>2020-09-08 16:53:37 -0400
commit7db68865b7560ca5d74aa6cd15656b3656ea7f42 (patch)
tree6d34692fdda54a66d9282fa855d6fcd0f5310a2b
parent677db04fae0af875685a71e0cedd408578071bef (diff)
downloadpango-avoid-script-lang-crash.tar.gz
Don't assert in pango_language_get_scriptsavoid-script-lang-crash
The assertion in pango_language_get_scripts can actually be triggered since we last regenerated the pango_script_for_lang table. It now includes an entry for und-zsye which has no scripts. Handle this case without asserting. This commit includes a test.
-rw-r--r--pango/pango-language.c2
-rw-r--r--tests/testmisc.c15
2 files changed, 16 insertions, 1 deletions
diff --git a/pango/pango-language.c b/pango/pango-language.c
index 575d4652..bb5ed470 100644
--- a/pango/pango-language.c
+++ b/pango/pango-language.c
@@ -662,7 +662,7 @@ pango_language_get_scripts (PangoLanguage *language,
script_for_lang,
pango_script_for_lang);
- if (!script_for_lang)
+ if (!script_for_lang || script_for_lang->scripts[0] == 0)
{
if (num_scripts)
*num_scripts = 0;
diff --git a/tests/testmisc.c b/tests/testmisc.c
index 9f1f24da..2f6c148b 100644
--- a/tests/testmisc.c
+++ b/tests/testmisc.c
@@ -73,6 +73,20 @@ test_short_string_crash (void)
g_object_unref (context);
}
+static void
+test_language_emoji_crash (void)
+{
+ PangoLanguage *lang;
+ const PangoScript *scripts;
+ int num;
+
+ lang = pango_language_from_string ("und-zsye");
+ scripts = pango_language_get_scripts (lang, &num);
+
+ g_assert (num >= 0);
+ g_assert (scripts == NULL || num > 0);
+}
+
int
main (int argc, char *argv[])
{
@@ -81,6 +95,7 @@ main (int argc, char *argv[])
g_test_add_func ("/layout/shape-tab-crash", test_shape_tab_crash);
g_test_add_func ("/layout/itemize-empty-crash", test_itemize_empty_crash);
g_test_add_func ("/layout/short-string-crash", test_short_string_crash);
+ g_test_add_func ("/language/emoji-crash", test_language_emoji_crash);
return g_test_run ();
}