From 882716f72970e95edd3101f70c5961ec42eeaffb Mon Sep 17 00:00:00 2001 From: xueyunfei Date: Fri, 30 Aug 2019 14:00:14 +0800 Subject: [PATCH] sockets: Fix potential race when socket is closed already Ref IDF-4794 --- src/api/sockets.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/api/sockets.c b/src/api/sockets.c index 6a9f6d0a..d2ca5649 100644 --- a/src/api/sockets.c +++ b/src/api/sockets.c @@ -443,6 +443,10 @@ tryget_socket_unconn_locked(int fd) { struct lwip_sock *ret = tryget_socket_unconn_nouse(fd); if (ret != NULL) { +#if ESP_LWIP + if (ret->conn == NULL) + return NULL; +#endif /* ESP_LWIP */ if (!sock_inc_used_locked(ret)) { return NULL; }