[pango/pango-1-44: 13/31] itemize: Work around gtk2 brokenness
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/pango-1-44: 13/31] itemize: Work around gtk2 brokenness
- Date: Sun, 9 May 2021 01:32:01 +0000 (UTC)
commit ac07f75e9c1c560f0e8243426ef4f12a2ff1a7e8
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Jun 10 11:36:24 2020 -0400
itemize: Work around gtk2 brokenness
GTK 2 apparently manages to call pango_itemize_with_base_dir
with a non-zero length for a string that contains 0 characters.
That in turn causes pango_log2vis_get_embedding_levels to
return NULL, and things go downhill from there.
A test is included.
Fixes: #480
(cherry-picked from commit 279bd525)
pango/pango-context.c | 2 +-
tests/testmisc.c | 14 ++++++++++++++
2 files changed, 15 insertions(+), 1 deletion(-)
---
diff --git a/pango/pango-context.c b/pango/pango-context.c
index f0bf11c3..d1c5a734 100644
--- a/pango/pango-context.c
+++ b/pango/pango-context.c
@@ -1571,7 +1571,7 @@ pango_itemize_with_base_dir (PangoContext *context,
g_return_val_if_fail (length >= 0, NULL);
g_return_val_if_fail (length == 0 || text != NULL, NULL);
- if (length == 0)
+ if (length == 0 || g_utf8_strlen (text, length) == 0)
return NULL;
itemize_state_init (&state, context, text, base_dir, start_index, length,
diff --git a/tests/testmisc.c b/tests/testmisc.c
index 3e629f24..a2784f13 100644
--- a/tests/testmisc.c
+++ b/tests/testmisc.c
@@ -38,12 +38,26 @@ test_shape_tab_crash (void)
g_object_unref (context);
}
+/* Test that itemizing a string with 0 characters works
+ */
+static void
+test_itemize_empty_crash (void)
+{
+ PangoContext *context;
+
+ context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
+ pango_itemize_with_base_dir (context, PANGO_DIRECTION_LTR, "", 0, 1, NULL, NULL);
+
+ g_object_unref (context);
+}
+
int
main (int argc, char *argv[])
{
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/layout/shape-tab-crash", test_shape_tab_crash);
+ g_test_add_func ("/layout/itemize-empty-crash", test_itemize_empty_crash);
return g_test_run ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]