From 2a400039ea3adeec43a927e606e5f6d78e012988 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 19 Jun 2010 13:05:02 +0200 Subject: [PATCH] screen_browser: check for error before adding song to playlist The function enqueue_and_play() may cause an assertion failure, because it evaluates the filelist_entry object after mpdclient_get_connection() call. However, mpdclient_get_connection() may indirectly invalidate the filelist_entry object, when it sees that the connection has become invalid; it will return a NULL connection then. This results in an assertion failure or a segmentation fault. --- NEWS | 1 + src/screen_browser.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/NEWS b/NEWS index b93ea55..526570d 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,6 @@ ncmpc 0.17 - not yet released * screen_queue: fix range selection check on "shuffle" +* screen_browser: check for error before adding song to playlist * po: added Brazilian Portuguese translation diff --git a/src/screen_browser.c b/src/screen_browser.c index 45e11eb..04673f4 100644 --- a/src/screen_browser.c +++ b/src/screen_browser.c @@ -143,6 +143,9 @@ static bool enqueue_and_play(struct mpdclient *c, struct filelist_entry *entry) { struct mpd_connection *connection = mpdclient_get_connection(c); + if (connection == NULL) + return false; + const struct mpd_song *song = mpd_entity_get_song(entry->entity); int id; -- 2.30.2