summaryrefslogtreecommitdiff
path: root/pango
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2019-08-08 08:31:43 -0700
committerMatthias Clasen <mclasen@redhat.com>2019-08-08 08:31:43 -0700
commit36a55406a86ceee67ee720bc81eb4c7c00fce267 (patch)
tree7ff153cc0b990018e6d1e7d56ae96b151e4abc3c /pango
parent6968eaf07afebc2cb6690183ca0528303609def2 (diff)
downloadpango-36a55406a86ceee67ee720bc81eb4c7c00fce267.tar.gz
Prevent a crash in ellipsization
We were crashing when ellipsizing text without any attributes. Test included.
Diffstat (limited to 'pango')
-rw-r--r--pango/ellipsize.c6
1 files changed, 5 insertions, 1 deletions
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)