diff options
author | Matthias Clasen <mclasen@redhat.com> | 2020-06-10 15:46:06 +0000 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2020-06-10 15:46:06 +0000 |
commit | 4b5e25a22cc0bb10c60cd43bef394e16f4a11846 (patch) | |
tree | c3960071bd5a79b2a242bb26fbcf3db4f6104bce | |
parent | c73c2d5d0258b0fc6f8408e6c8fce09cd273d20e (diff) | |
parent | 279bd5256b17ed68d50fbaaf7df60f189de33c96 (diff) | |
download | pango-4b5e25a22cc0bb10c60cd43bef394e16f4a11846.tar.gz |
Merge branch 'fix-another-crash' into 'master'
itemize: Work around gtk2 brokenness
Closes #480
See merge request GNOME/pango!198
-rw-r--r-- | pango/pango-context.c | 2 | ||||
-rw-r--r-- | tests/testmisc.c | 14 |
2 files changed, 15 insertions, 1 deletions
diff --git a/pango/pango-context.c b/pango/pango-context.c index 7772878f..bebe804a 100644 --- a/pango/pango-context.c +++ b/pango/pango-context.c @@ -1566,7 +1566,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 a078944d..f5583cab 100644 --- a/tests/testmisc.c +++ b/tests/testmisc.c @@ -41,12 +41,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 (); } |