]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Do not leak file handle on _open_osfhandle() failure (#2222)
authorJoshua Rogers <MegaManSec@users.noreply.github.com>
Tue, 9 Sep 2025 17:15:26 +0000 (17:15 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Tue, 9 Sep 2025 17:15:31 +0000 (17:15 +0000)
compat/socket.cc

index 16bca103c4abf5026cd13cc5770f0bccfbb0b256..5fac7c22448bcb6d447b6b0839108746f9d3ac31 100644 (file)
@@ -225,8 +225,11 @@ xsocket(int domain, int type, int protocol)
         return SOCKET_ERROR;
     }
     const auto rv = _open_osfhandle(result, 0);
-    if (rv == -1)
+    if (rv == -1) {
+        closesocket(result);
         errno = EBADF;
+        return SOCKET_ERROR;
+    }
     return rv;
 }