summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 61053ab)
raw | patch | inline | side by side (parent: 61053ab)
author | Max Kellermann <max@duempel.org> | |
Sun, 21 Sep 2008 17:48:39 +0000 (19:48 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Sun, 21 Sep 2008 19:51:01 +0000 (21:51 +0200) |
mpd_wait() must not be called when the socket is dead; add an
assertion there. In mpd_recv(), add a run-time check.
assertion there. In mpd_recv(), add a run-time check.
src/libmpdclient.c | patch | blob | history |
diff --git a/src/libmpdclient.c b/src/libmpdclient.c
index 0f2b1b503d73b101c6a68cd23d6a2c2a53a43b4e..2b4a52c85458a348826a3f6743cf9714cd6cdf6d 100644 (file)
--- a/src/libmpdclient.c
+++ b/src/libmpdclient.c
fd_set fds;
int ret;
+ assert(connection->sock >= 0);
+
while (1) {
tv = connection->timeout;
FD_ZERO(&fds);
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;