From dd6ce709db5872132335fef9f75aa16a33d6e5aa Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 6 Apr 2009 19:49:02 -0400 Subject: [layout] Truncate final whitespace in the line before ellipsizing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug 556132 – gnome-panel crashed with SIGSEGV in g_cclosure_marshal_VOID__BOXED() Not after. Also fixes invalid memory access in case line was both wrapped and ellipsized. --- pango/pango-layout.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/pango/pango-layout.c b/pango/pango-layout.c index b1b75a4f..4326eb47 100644 --- a/pango/pango-layout.c +++ b/pango/pango-layout.c @@ -5166,18 +5166,21 @@ pango_layout_line_postprocess (PangoLayoutLine *line, ParaBreakState *state, gboolean wrapped) { - PangoLayoutRun *last_run = line->runs->data; gboolean ellipsized = FALSE; - /* NB: the runs are in reverse order at this point, since we prepended them to the list + DEBUG ("postprocessing", line, state); + + /* Truncate the logical-final whitespace in the line if we broke the line at it */ + if (wrapped) + /* The runs are in reverse order at this point, since we prepended them to the list. + * So, the first run is the last logical run. */ + zero_line_final_space (line, state, line->runs->data); /* Reverse the runs */ line->runs = g_slist_reverse (line->runs); - DEBUG ("postprocessing", line, state); - /* Ellipsize the line if necessary */ if (G_UNLIKELY (state->line_width >= 0 && @@ -5186,11 +5189,6 @@ pango_layout_line_postprocess (PangoLayoutLine *line, ellipsized = _pango_layout_line_ellipsize (line, state->attrs, state->line_width); } - /* Truncate the logical-final whitespace in the line if we broke the line at it - */ - if (wrapped) - zero_line_final_space (line, state, last_run); - DEBUG ("after removing final space", line, state); /* Now convert logical to visual order -- cgit v1.2.1