From e026481f11554580b234618e6a80242a6a9a50b1 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Mon, 19 May 2014 10:37:21 +0200 Subject: listbox_resize(): Avoid segmentation fault Only try to fix the visible region if an item is selected. Signed-off-by: Lukas Fleischer --- src/listbox.c | 4 ++++ 1 file changed, 4 insertions(+) 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); } -- cgit v1.2.3