From: Max Kellermann Date: Sat, 3 Oct 2009 16:21:15 +0000 (+0200) Subject: screen_artist: check cursor position in cmd() method X-Git-Tag: release-0.16~201 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=aeedcd66d699fa8e64df5ca75cf0d2f2c1957e08;p=ncmpc.git screen_artist: check cursor position in cmd() method Fix segmentation faults when the list is empty. --- diff --git a/src/screen_artist.c b/src/screen_artist.c index 5c0ff30..95e4d22 100644 --- a/src/screen_artist.c +++ b/src/screen_artist.c @@ -470,6 +470,9 @@ screen_artist_cmd(struct mpdclient *c, command_t cmd) case CMD_PLAY: switch (mode) { case LIST_ARTISTS: + if (browser.lw->selected >= artist_list->len) + return true; + selected = g_ptr_array_index(artist_list, browser.lw->selected); open_album_list(c, g_strdup(selected)); @@ -603,6 +606,9 @@ screen_artist_cmd(struct mpdclient *c, command_t cmd) case CMD_ADD: switch(mode) { case LIST_ARTISTS: + if (browser.lw->selected >= artist_list->len) + return true; + for (unsigned i = browser.lw->selected_start; i <= browser.lw->selected_end; ++i) { selected = g_ptr_array_index(artist_list, i);