Code

check the return value of mpdclient_get_connection()
[ncmpc.git] / src / utils.c
index 6042848bced918cab0378fdd4764a7014f7c826b..84db64a5b122211081fc0df2a02e206411befb51 100644 (file)
@@ -79,10 +79,10 @@ gcmp_list_from_path(struct mpdclient *c, const gchar *path,
        struct mpd_connection *connection;
        struct mpd_entity *entity;
 
-       if (!mpdclient_is_connected(c))
+       connection = mpdclient_get_connection(c);
+       if (connection == NULL)
                return list;
 
-       connection = mpdclient_get_connection(c);
        mpd_send_list_meta(connection, path);
 
        while ((entity = mpd_recv_entity(connection)) != NULL) {