fixed small crash bug in ClientSocket.c:socket_loop
authorpk910 <philipp@zoelle1.de>
Fri, 23 Dec 2011 01:06:20 +0000 (02:06 +0100)
committerpk910 <philipp@zoelle1.de>
Fri, 23 Dec 2011 01:06:20 +0000 (02:06 +0100)
src/ClientSocket.c

index 16ad26d4b9a0d7979f3678826bfc239fe84684dd..6b8b4fb815d5f4728414e9cf30f14998ad1c73d5 100644 (file)
@@ -353,7 +353,7 @@ void socket_loop(int timeout_seconds) {
     if(sockets == NULL) return;
     fd_set fds;
     struct timeval timeout;
-    struct ClientSocket *sock;
+    struct ClientSocket *sock, *next;
     int ret = 0, bytes, i;
     
     FD_ZERO(&fds);
@@ -367,7 +367,8 @@ void socket_loop(int timeout_seconds) {
     timeout.tv_usec = 0;
     ret = select(ret + 1, &fds, NULL, NULL, &timeout);
     if(ret == 0) return;
-    for (sock = sockets->data; sock; sock = sock->next) {
+    for (sock = sockets->data; sock; sock = next) {
+        next = sock->next;
         if((sock->flags & SOCKET_FLAG_CONNECTED) && FD_ISSET(sock->sock, &fds)) {
             if(sock->bufferpos != 0) {
                 if(!(sock->flags & SOCKET_FLAG_HAVE_SSL) || (bytes = ssl_read(sock, buffer, sizeof(buffer))) == -2) {