svn commit: r197174 - head/sys/dev/syscons

Ed Schouten ed at FreeBSD.org
Sun Sep 13 18:45:59 UTC 2009


Author: ed
Date: Sun Sep 13 18:45:59 2009
New Revision: 197174
URL: http://svn.freebsd.org/changeset/base/197174

Log:
  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

Modified:
  head/sys/dev/syscons/scterm-teken.c

Modified: head/sys/dev/syscons/scterm-teken.c
==============================================================================
--- head/sys/dev/syscons/scterm-teken.c	Sun Sep 13 17:45:31 2009	(r197173)
+++ head/sys/dev/syscons/scterm-teken.c	Sun Sep 13 18:45:59 2009	(r197174)
@@ -137,9 +137,12 @@ scteken_init(scr_stat *scp, void **softc
 		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;
 	}
 


More information about the svn-src-all mailing list