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>
This commit is contained in:
Lukas Fleischer 2014-05-19 10:37:21 +02:00
parent d971d7aa35
commit e026481f11

View File

@ -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);
}