From: Grigori Goronzy Date: Sun, 17 Jul 2011 11:53:29 +0000 (+0200) Subject: Fix line counting and breaking X-Git-Tag: 0.10.0~32 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2f01497b9974ab083b99bed3823bbf9702ad8b9a;p=libass 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. --- 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))