Code

mpdclient: check source again after mpd_glib_leave()
authorMax Kellermann <max.kellermann@gmail.com>
Tue, 17 Oct 2017 13:56:06 +0000 (15:56 +0200)
committerMax Kellermann <max.kellermann@gmail.com>
Tue, 17 Oct 2017 13:56:06 +0000 (15:56 +0200)
Just in case mpd_glib_leave() has found an error and had to close the
connection, check it again to avoid an assertion failure (or crash) in
mpdclient_schedule_enter_idle().

Closes #9

NEWS
src/mpdclient.c

diff --git a/NEWS b/NEWS
index d809ad63d00c15d4a94990fae3e5ed21a8058153..ab2d153cc07cc3ad78b5309f2e6b724adef12ef0 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,5 @@
 ncmpc 0.29 - not yet released
+* fix crash after losing MPD connection
 
 ncmpc 0.28 - (2017-09-21)
 * fix crash on lyrics screen
index 6a81a0bd8ac20bd6cc2708f3438ad194a28ba643..1801ad2dc7973b94e927131f5bdd1c3a95127f7d 100644 (file)
@@ -490,7 +490,8 @@ mpdclient_get_connection(struct mpdclient *c)
                c->idle = false;
                mpd_glib_leave(c->source);
 
-               mpdclient_schedule_enter_idle(c);
+               if (c->source != NULL)
+                       mpdclient_schedule_enter_idle(c);
        }
 
        return c->connection;