From 36a55406a86ceee67ee720bc81eb4c7c00fce267 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 8 Aug 2019 08:31:43 -0700 Subject: Prevent a crash in ellipsization We were crashing when ellipsizing text without any attributes. Test included. --- pango/ellipsize.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'pango/ellipsize.c') diff --git a/pango/ellipsize.c b/pango/ellipsize.c index 002853c3..304d89fc 100644 --- a/pango/ellipsize.c +++ b/pango/ellipsize.c @@ -119,7 +119,10 @@ init_state (EllipsizeState *state, int start_offset; state->layout = line->layout; - state->attrs = attrs; + if (attrs) + state->attrs = pango_attr_list_ref (attrs); + else + state->attrs = pango_attr_list_new (); state->n_runs = g_slist_length (line->runs); state->run_info = g_new (RunInfo, state->n_runs); @@ -151,6 +154,7 @@ init_state (EllipsizeState *state, static void free_state (EllipsizeState *state) { + pango_attr_list_unref (state->attrs); if (state->line_start_attr) pango_attr_iterator_destroy (state->line_start_attr); if (state->gap_start_attr) -- cgit v1.2.1