From 33ce6cd8f885e8bdaab7c058d65a3c2193463ab9 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Wed, 8 Jun 2011 16:46:24 +0200 Subject: Avoid segfault in getstr_fixscr() Avoid a segfault that may occur if getstr_fixscr() changes the scroll offset to something outside the input boundaries (e.g. if a word that is only partly visible is killed via backward-kill-word). Signed-off-by: Lukas Fleischer --- src/getstring.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/getstring.c') diff --git a/src/getstring.c b/src/getstring.c index 3b9e865..8633ef3 100644 --- a/src/getstring.c +++ b/src/getstring.c @@ -154,7 +154,7 @@ getstr_fixscr (struct getstr_status *st) while (st->pos < st->scrpos) { pgskip = 0; - while (pgskip < pgsize) + while (pgskip < pgsize && st->scrpos > 0) { st->scrpos--; pgskip += st->ci[st->scrpos + 1].dpyoff - st->ci[st->scrpos].dpyoff; @@ -163,7 +163,7 @@ getstr_fixscr (struct getstr_status *st) while (st->ci[st->pos].dpyoff - st->ci[st->scrpos].dpyoff > col - 2) { pgskip = 0; - while (pgskip < pgsize) + while (pgskip < pgsize && st->scrpos < st->len) { pgskip += st->ci[st->scrpos + 1].dpyoff - st->ci[st->scrpos].dpyoff; st->scrpos++; -- cgit v1.2.3-54-g00ecf