Code

mpdclient: handle password errors properly in mpdclient_connect()
authorMax Kellermann <max@duempel.org>
Tue, 29 Sep 2009 21:18:02 +0000 (23:18 +0200)
committerMax Kellermann <max@duempel.org>
Tue, 29 Sep 2009 21:18:02 +0000 (23:18 +0200)
Abort the connection when the configured password fails.

src/mpdclient.c

index 5e138edca16b085a6fc60ab78add92fd04dd7cca..77638d65c7b5691d4190200989dafc8d5bdcf5eb 100644 (file)
@@ -186,8 +186,6 @@ mpdclient_connect(struct mpdclient *c,
                  gfloat _timeout,
                  const gchar *password)
 {
-       gint retval = 0;
-
        /* close any open connection */
        if( c->connection )
                mpdclient_disconnect(c);
@@ -204,9 +202,10 @@ mpdclient_connect(struct mpdclient *c,
        }
 
        /* send password */
-       if( password ) {
-               mpd_send_password(c->connection, password);
-               retval = mpdclient_finish_command(c);
+       if (password != NULL && !mpd_run_password(c->connection, password)) {
+               mpdclient_handle_error(c);
+               mpdclient_disconnect(c);
+               return false;
        }
 
        return true;