]> granicus.if.org Git - python/commitdiff
Issue #19182: Fixed socket leak on exception when connecting.
authorVinay Sajip <vinay_sajip@yahoo.co.uk>
Sun, 6 Oct 2013 17:36:00 +0000 (18:36 +0100)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>
Sun, 6 Oct 2013 17:36:00 +0000 (18:36 +0100)
Lib/logging/handlers.py

index b0b0a1660f08dcc6ab487124f34c203ef729a285..b2e7d445cf9a78b0a59f84d9c6468038aef3b0e1 100644 (file)
@@ -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):