[pango/pango-1-44] Don't assert in pango_language_get_scripts
- From: Marco Trevisan <marcotrevi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/pango-1-44] Don't assert in pango_language_get_scripts
- Date: Wed, 5 May 2021 16:00:30 +0000 (UTC)
commit 75e077b2e69ab207fa862b9002127b0a1174de05
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Sep 8 16:49:43 2020 -0400
Don't assert in pango_language_get_scripts
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.
(cherry-picked from commit 7db68865)
pango/pango-language.c | 2 +-
tests/testmisc.c | 15 +++++++++++++++
2 files changed, 16 insertions(+), 1 deletion(-)
---
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 b2aac796..8cfd8e12 100644
--- a/tests/testmisc.c
+++ b/tests/testmisc.c
@@ -70,6 +70,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[])
{
@@ -78,6 +92,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 ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]