screen: don't crash on invalid grid cells being recomposed

This commit is contained in:
Björn Linse
2019-09-01 11:13:13 +02:00
parent dc52458522
commit dd26bd5974
4 changed files with 25 additions and 2 deletions

View File

@@ -518,10 +518,11 @@ EXTERN long p_pyx; // 'pyxversion'
EXTERN char_u *p_rdb; // 'redrawdebug'
EXTERN unsigned rdb_flags;
# ifdef IN_OPTION_C
static char *(p_rdb_values[]) = { "compositor", "nothrottle", NULL };
static char *(p_rdb_values[]) = { "compositor", "nothrottle", "invalid", NULL };
# endif
# define RDB_COMPOSITOR 0x001
# define RDB_NOTHROTTLE 0x002
# define RDB_INVALID 0x004
EXTERN long p_rdt; // 'redrawtime'
EXTERN int p_remap; // 'remap'

View File

@@ -425,6 +425,15 @@ static void compose_line(Integer row, Integer startcol, Integer endcol,
flags = flags & ~kLineFlagWrap;
}
for (int i = skipstart; i < (endcol-skipend)-startcol; i++) {
if (attrbuf[i] < 0) {
if (rdb_flags & RDB_INVALID) {
abort();
} else {
attrbuf[i] = 0;
}
}
}
ui_composed_call_raw_line(1, row, startcol+skipstart,
endcol-skipend, endcol-skipend, 0, flags,
(const schar_T *)linebuf+skipstart,
@@ -535,6 +544,11 @@ static void ui_comp_raw_line(UI *ui, Integer grid, Integer row,
} else {
compose_debug(row, row+1, startcol, endcol, dbghl_normal, false);
compose_debug(row, row+1, endcol, clearcol, dbghl_clear, true);
#ifndef NDEBUG
for (int i = 0; i < endcol-startcol; i++) {
assert(attrs[i] >= 0);
}
#endif
ui_composed_call_raw_line(1, row, startcol, endcol, clearcol, clearattr,
flags, chunk, attrs);
}