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 <calcurse@cryptocrack.de>
This commit is contained in:
parent
e85501e5ef
commit
33ce6cd8f8
@ -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++;
|
||||
|
Loading…
x
Reference in New Issue
Block a user