From: Vinay Sajip Date: Sun, 6 Oct 2013 17:36:00 +0000 (+0100) Subject: Issue #19182: Fixed socket leak on exception when connecting. X-Git-Tag: v3.4.0a4~219 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=38c741c1fcd432fa8740bed263c82339f9cc0b70;p=thirdparty%2FPython%2Fcpython.git Issue #19182: Fixed socket leak on exception when connecting. --- diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py index b0b0a1660f08..b2e7d445cf9a 100644 --- a/Lib/logging/handlers.py +++ b/Lib/logging/handlers.py @@ -518,7 +518,11 @@ class SocketHandler(logging.Handler): else: result = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) result.settimeout(timeout) - result.connect(self.address) + try: + result.connect(self.address) + except OSError: + result.close() # Issue 19182 + raise return result def createSocket(self):