소스 검색

Fix leaked handle in create_socket (#1554)

Fixes resource leak problem detected by Coverity Scan.
Oleg Shparber 3 년 전
부모
커밋
c2e156e0e0
1개의 변경된 파일4개의 추가작업 그리고 1개의 파일을 삭제
  1. 4 1
      httplib.h

+ 4 - 1
httplib.h

@@ -2728,7 +2728,10 @@ socket_t create_socket(const std::string &host, const std::string &ip, int port,
     if (sock == INVALID_SOCKET) { continue; }
 
 #ifndef _WIN32
-    if (fcntl(sock, F_SETFD, FD_CLOEXEC) == -1) { continue; }
+    if (fcntl(sock, F_SETFD, FD_CLOEXEC) == -1) {
+      close_socket(sock);
+      continue;
+    }
 #endif
 
     if (tcp_nodelay) {