Make sure we never place the cursor outside the screen.

For some vague reason, it may be possible that scp->cursor_pos exceeds
scp->ysize * scp->xsize. This means that teken_set_cursor() may get
called with an invalid position. Just ignore the old cursor position in
this case.

Reported by:	Paul B. Mahol <onemda gmail com>
MFC after:	1 month
This commit is contained in:
Ed Schouten 2009-09-13 18:45:59 +00:00
parent f3d06a3c68
commit 94dc815e34

View File

@ -137,9 +137,12 @@ scteken_init(scr_stat *scp, void **softc, int code)
tp.tp_col = scp->xsize;
teken_set_winsize(&ts->ts_teken, &tp);
tp.tp_row = scp->cursor_pos / scp->xsize;
tp.tp_col = scp->cursor_pos % scp->xsize;
teken_set_cursor(&ts->ts_teken, &tp);
if (scp->cursor_pos < scp->ysize * scp->xsize) {
/* Valid old cursor position. */
tp.tp_row = scp->cursor_pos / scp->xsize;
tp.tp_col = scp->cursor_pos % scp->xsize;
teken_set_cursor(&ts->ts_teken, &tp);
}
break;
}