Code

mpdclient: check errorCode only if MPD_ERROR_ACK is set
authorMax Kellermann <max@duempel.org>
Sun, 21 Sep 2008 20:42:52 +0000 (22:42 +0200)
committerMax Kellermann <max@duempel.org>
Sun, 21 Sep 2008 20:42:52 +0000 (22:42 +0200)
connection->errorCode has an undefined value when connection->error is
not MPD_ERROR_ACK.  Read it only if MPD_ERROR_ACK is set, to make
valgrind happy.

src/mpdclient.c

index fcdaa4ef452c0923d36d56ad235cc47ce6e0e36a..caa9fe3a951eafe0a3467d2a65798cec3557b297 100644 (file)
@@ -126,7 +126,8 @@ mpdclient_finish_command(mpdclient_t *c)
                gint error = c->connection->error;
                gchar *msg;
 
-               if (c->connection->errorCode == MPD_ACK_ERROR_PERMISSION &&
+               if (error == MPD_ERROR_ACK &&
+                   c->connection->errorCode == MPD_ACK_ERROR_PERMISSION &&
                    screen_auth(c) == 0)
                        return 0;