aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-09-21 22:44:04 +0200
committerMax Kellermann <max@duempel.org>2008-09-21 22:44:04 +0200
commitc239d890383d54d717da16a19b7977bf31dfc9b1 (patch)
treedc716567db11f854f1b0563935d853add93141c9 /src
parent54f4d47d8f0d4f7e0288a140c49b82999885e329 (diff)
downloadmpd-c239d890383d54d717da16a19b7977bf31dfc9b1.tar.gz
mpd-c239d890383d54d717da16a19b7977bf31dfc9b1.tar.xz
mpd-c239d890383d54d717da16a19b7977bf31dfc9b1.zip
screen_artist: check if anything is selected
Don't try to call add_query() with no valid selection, this causes a segfault. This usually happens when ncmpc isn't connected.
Diffstat (limited to 'src')
-rw-r--r--src/screen_artist.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/screen_artist.c b/src/screen_artist.c
index 71be6f408..2f97c723a 100644
--- a/src/screen_artist.c
+++ b/src/screen_artist.c
@@ -272,6 +272,8 @@ add_query(mpdclient_t *c, int table, char *_filter)
char *str;
mpdclient_filelist_t *addlist;
+ assert(filter != NULL);
+
str = utf8_to_locale(_filter);
if (table== MPD_TABLE_ALBUM)
screen_status_printf("Adding album %s...", str);
@@ -381,6 +383,9 @@ artist_cmd(screen_t *screen, mpdclient_t *c, command_t cmd)
case LIST_ARTISTS:
selected = g_list_nth_data(metalist,
browser.lw->selected);
+ if (selected == NULL)
+ return 1;
+
add_query(c, MPD_TABLE_ARTIST, selected);
cmd = CMD_LIST_NEXT; /* continue and select next item... */
break;
@@ -392,6 +397,9 @@ artist_cmd(screen_t *screen, mpdclient_t *c, command_t cmd)
else if (browser.lw->selected > 0) {
selected = g_list_nth_data(metalist,
browser.lw->selected);
+ if (selected == NULL)
+ return 1;
+
add_query(c, MPD_TABLE_ALBUM, selected);
cmd = CMD_LIST_NEXT; /* continue and select next item... */
}