wrap code - line2 COULD be NULL technically, so handle that case

This commit is contained in:
Carsten Haitzler 2013-12-06 19:00:23 +09:00
parent 05d091483a
commit 6cbc4c1a09
1 changed files with 12 additions and 9 deletions

View File

@ -639,7 +639,7 @@ termpty_line_rewrap(Termpty *ty, int y_start, int y_end,
int x, x2, y, y2, y2_start; int x, x2, y, y2, y2_start;
int len, len_last, len_remaining, copy_width, ts2_width; int len, len_last, len_remaining, copy_width, ts2_width;
Termsave *ts, *ts2; Termsave *ts, *ts2;
Termcell *line, *line2; Termcell *line, *line2 = NULL;
if (y_end >= 0) if (y_end >= 0)
{ {
@ -714,15 +714,18 @@ termpty_line_rewrap(Termpty *ty, int y_start, int y_end,
back2[y2 + ty->backmax] = ts2; back2[y2 + ty->backmax] = ts2;
} }
} }
termpty_cell_copy(ty, line + x, line2 + x2, copy_width); if (line2)
x += copy_width;
x2 += copy_width;
len_remaining -= copy_width;
if ((x2 == w2) && (y2 != y2_end))
{ {
line2[x2 - 1].att.autowrapped = 1; termpty_cell_copy(ty, line + x, line2 + x2, copy_width);
x2 = 0; x += copy_width;
y2++; x2 += copy_width;
len_remaining -= copy_width;
if ((x2 == w2) && (y2 != y2_end))
{
line2[x2 - 1].att.autowrapped = 1;
x2 = 0;
y2++;
}
} }
} }
x = 0; x = 0;