]> granicus.if.org Git - libass/commitdiff
Fix line counting and breaking
authorGrigori Goronzy <greg@blackbox>
Sun, 17 Jul 2011 11:53:29 +0000 (13:53 +0200)
committerGrigori Goronzy <greg@blackbox>
Sun, 17 Jul 2011 11:55:01 +0000 (13:55 +0200)
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

index 0ac1ff992a72216d7aca0bf5aee6aa5d42dbf2bb..8d82a7484e0355c44741c7e7225c8ae506840e68 100644 (file)
@@ -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))