From: Marko Kreen Date: Fri, 21 Jan 2011 11:33:05 +0000 (+0200) Subject: socket: poll compat fix X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=d7a0cc3ce37719d4e03d71a6cfd1f05ab8ccf82a;p=libusual.git socket: poll compat fix --- diff --git a/usual/socket.c b/usual/socket.c index 77d961e..1b9f678 100644 --- a/usual/socket.c +++ b/usual/socket.c @@ -278,8 +278,9 @@ static bool fdbuf_resize(struct fd_buf *buf, int fd) int alloc = sizeof(fd_set); #ifdef WIN32 + int cnt = buf->set ? buf->set->fd_count : 0; /* win32 fd_set is array of handles, +8 for count&padding */ - need_bytes = (buf->set->fd_count + 1) * sizeof(buf->set->fd_array[0]) + 8; + need_bytes = (cnt + 1) * sizeof(buf->set->fd_array[0]) + 8; #else /* otherwise, fd_set is bitmap, +8 for int/long alignment */ need_bytes = fd / 8 + 8;