aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2014-05-19 10:37:21 +0200
committerLukas Fleischer <calcurse@cryptocrack.de>2014-05-19 10:37:21 +0200
commite026481f11554580b234618e6a80242a6a9a50b1 (patch)
treef6be17b7d31fffed5b5bdcd0ac61065c42bcac1d
parentd971d7aa352a47d2a6e8043125033ceacb99deab (diff)
downloadcalcurse-e026481f11554580b234618e6a80242a6a9a50b1.tar.gz
calcurse-e026481f11554580b234618e6a80242a6a9a50b1.zip
listbox_resize(): Avoid segmentation fault
Only try to fix the visible region if an item is selected. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
-rw-r--r--src/listbox.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/listbox.c b/src/listbox.c
index 245eeef..7f67fe4 100644
--- a/src/listbox.c
+++ b/src/listbox.c
@@ -64,6 +64,10 @@ void listbox_resize(struct listbox *lb, int y, int x, int h, int w)
{
EXIT_IF(lb == NULL, "null pointer");
wins_scrollwin_resize(&(lb->sw), y, x, h, w);
+
+ if (lb->item_sel < 0)
+ return;
+
wins_scrollwin_ensure_visible(&(lb->sw), lb->ch[lb->item_sel]);
wins_scrollwin_ensure_visible(&(lb->sw), lb->ch[lb->item_sel + 1] - 1);
}