diff --git a/lib/client-handshake.c b/lib/client-handshake.c index ceb5f76f..556b518f 100644 --- a/lib/client-handshake.c +++ b/lib/client-handshake.c @@ -138,9 +138,15 @@ struct libwebsocket *__libwebsocket_client_connect_2( wsi->mode = LWS_CONNMODE_WS_CLIENT_ISSUE_HANDSHAKE; pfd.fd = wsi->sock; pfd.revents = POLLIN; - if (libwebsocket_service_fd(context, &pfd) < 0) + + n = libwebsocket_service_fd(context, &pfd); + + if (n < 0) goto oom4; + if (n) /* returns 1 on failure after closing wsi */ + return NULL; + return wsi; oom4: