From 2f01497b9974ab083b99bed3823bbf9702ad8b9a Mon Sep 17 00:00:00 2001 From: Grigori Goronzy Date: Sun, 17 Jul 2011 13:53:29 +0200 Subject: Fix line counting and breaking Make sure to increment the line counter only if the offset of the new line is actually legal and inside the bounds of the text size. Fixes random crashes in case the last symbol of the line is a break. git-blame says it's Evgeniys fault, it wasn't caused by the recent layout changes. --- libass/ass_render.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/libass/ass_render.c b/libass/ass_render.c index 0ac1ff9..8d82a74 100644 --- a/libass/ass_render.c +++ b/libass/ass_render.c @@ -1529,12 +1529,13 @@ wrap_lines_smart(ASS_Renderer *render_priv, double max_text_width) sizeof(LineInfo) * text_info->max_lines); } - if (lead < text_info->length) + if (lead < text_info->length) { text_info->glyphs[lead].linebreak = break_type; - last_space = -1; - s1 = text_info->glyphs + lead; - s_offset = d6_to_double(s1->bbox.xMin + s1->pos.x); - text_info->n_lines++; + last_space = -1; + s1 = text_info->glyphs + lead; + s_offset = d6_to_double(s1->bbox.xMin + s1->pos.x); + text_info->n_lines++; + } } } #define DIFF(x,y) (((x) < (y)) ? (y - x) : (x - y)) -- cgit v1.2.3