diff options
author | Lukas Fleischer <calcurse@cryptocrack.de> | 2014-05-19 10:37:21 +0200 |
---|---|---|
committer | Lukas Fleischer <calcurse@cryptocrack.de> | 2014-05-19 10:37:21 +0200 |
commit | e026481f11554580b234618e6a80242a6a9a50b1 (patch) | |
tree | f6be17b7d31fffed5b5bdcd0ac61065c42bcac1d /src/listbox.c | |
parent | d971d7aa352a47d2a6e8043125033ceacb99deab (diff) | |
download | 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>
Diffstat (limited to 'src/listbox.c')
-rw-r--r-- | src/listbox.c | 4 |
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); } |