diff options
author | Aleksandr Rybalko <ray@FreeBSD.org> | 2014-02-06 11:38:39 +0000 |
---|---|---|
committer | Aleksandr Rybalko <ray@FreeBSD.org> | 2014-02-06 11:38:39 +0000 |
commit | f821d023acf268b32f5a5c30a3239e6177cd66f6 (patch) | |
tree | 9f7dd7843555226d5e75a55b0682afdc4add6fa9 /sys/teken | |
parent | c79a4afc209406f028df9835afcb8c34d54c9526 (diff) | |
download | src-f821d023acf268b32f5a5c30a3239e6177cd66f6.tar.gz src-f821d023acf268b32f5a5c30a3239e6177cd66f6.zip |
Fix crash on load of bigger font. It reduce width and height of terminal, but
current cursor position stay bigger that terminal window size, so next input
triggers assert.
Reported by: emaste
Sponsored by: The FreeBSD Foundation
Notes
Notes:
svn path=/head/; revision=261547
Diffstat (limited to 'sys/teken')
-rw-r--r-- | sys/teken/teken.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/sys/teken/teken.c b/sys/teken/teken.c index a54c9f96e044..0613255f4388 100644 --- a/sys/teken/teken.c +++ b/sys/teken/teken.c @@ -338,10 +338,26 @@ teken_get_winsize(teken_t *t) return (&t->t_winsize); } +static void +taken_trim_cursor_pos(teken_t *t, const teken_pos_t *new) +{ + const teken_pos_t *cur; + + cur = &t->t_winsize; + + if (cur->tp_row < new->tp_row || cur->tp_col < new->tp_col) + return; + if (t->t_cursor.tp_row >= new->tp_row) + t->t_cursor.tp_row = new->tp_row - 1; + if (t->t_cursor.tp_col >= new->tp_col) + t->t_cursor.tp_col = new->tp_col - 1; +} + void teken_set_winsize(teken_t *t, const teken_pos_t *p) { + taken_trim_cursor_pos(t, p); t->t_winsize = *p; teken_subr_do_reset(t); } @@ -350,6 +366,7 @@ void teken_set_winsize_noreset(teken_t *t, const teken_pos_t *p) { + taken_trim_cursor_pos(t, p); t->t_winsize = *p; teken_subr_do_resize(t); } |