aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2011-06-08 16:46:24 +0200
committerLukas Fleischer <calcurse@cryptocrack.de>2011-07-02 10:09:17 +0200
commit33ce6cd8f885e8bdaab7c058d65a3c2193463ab9 (patch)
tree3416d816359a0664f43c7a6dedef1fbf0a748072 /src
parente85501e5ef0d990539090f4d12dbb3eae487c971 (diff)
downloadcalcurse-33ce6cd8f885e8bdaab7c058d65a3c2193463ab9.tar.gz
calcurse-33ce6cd8f885e8bdaab7c058d65a3c2193463ab9.zip
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>
Diffstat (limited to 'src')
-rw-r--r--src/getstring.c4
1 files changed, 2 insertions, 2 deletions
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++;