aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/libmpdclient.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/libmpdclient.c b/src/libmpdclient.c
index 0f2b1b503..2b4a52c85 100644
--- a/src/libmpdclient.c
+++ b/src/libmpdclient.c
@@ -213,6 +213,8 @@ static int mpd_wait(mpd_Connection *connection)
fd_set fds;
int ret;
+ assert(connection->sock >= 0);
+
while (1) {
tv = connection->timeout;
FD_ZERO(&fds);
@@ -265,6 +267,14 @@ static int mpd_recv(mpd_Connection *connection)
assert(connection->buflen <= sizeof(connection->buffer));
assert(connection->bufstart <= connection->buflen);
+ if (connection->sock < 0) {
+ strcpy(connection->errorStr, "not connected");
+ connection->error = MPD_ERROR_CONNCLOSED;
+ connection->doneProcessing = 1;
+ connection->doneListOk = 0;
+ return -1;
+ }
+
if (connection->buflen >= sizeof(connection->buffer)) {
/* delete consumed data from beginning of buffer */
connection->buflen -= connection->bufstart;