diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2024-02-01 01:00:09 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-01 01:00:09 (GMT) |
commit | 0ee6fbaab6888dc0252c497b13a7ba73f5172931 (patch) | |
tree | ffca0e470b16399dd3d10611e4b94e47374d08f0 /Lib/asyncio | |
parent | 21b68a1198fbfada3d3c11576c0f9676a4cf5978 (diff) | |
download | cpython-0ee6fbaab6888dc0252c497b13a7ba73f5172931.zip cpython-0ee6fbaab6888dc0252c497b13a7ba73f5172931.tar.gz cpython-0ee6fbaab6888dc0252c497b13a7ba73f5172931.tar.bz2 |
[3.12] gh-109534: fix reference leak when SSL handshake fails (GH-114074) (#114829)
gh-109534: fix reference leak when SSL handshake fails (GH-114074)
(cherry picked from commit 80aa7b3688b8fdc85cd53d4113cb5f6ce5500027)
Co-authored-by: Jamie Phan <jamie@ordinarylab.dev>
Diffstat (limited to 'Lib/asyncio')
-rw-r--r-- | Lib/asyncio/selector_events.py | 4 | ||||
-rw-r--r-- | Lib/asyncio/sslproto.py | 1 |
2 files changed, 5 insertions, 0 deletions
diff --git a/Lib/asyncio/selector_events.py b/Lib/asyncio/selector_events.py index f895750..790711f 100644 --- a/Lib/asyncio/selector_events.py +++ b/Lib/asyncio/selector_events.py @@ -235,6 +235,10 @@ class BaseSelectorEventLoop(base_events.BaseEventLoop): await waiter except BaseException: transport.close() + # gh-109534: When an exception is raised by the SSLProtocol object the + # exception set in this future can keep the protocol object alive and + # cause a reference cycle. + waiter = None raise # It's now up to the protocol to handle the connection. diff --git a/Lib/asyncio/sslproto.py b/Lib/asyncio/sslproto.py index 4d2cf82..e51669a 100644 --- a/Lib/asyncio/sslproto.py +++ b/Lib/asyncio/sslproto.py @@ -579,6 +579,7 @@ class SSLProtocol(protocols.BufferedProtocol): peercert = sslobj.getpeercert() except Exception as exc: + handshake_exc = None self._set_state(SSLProtocolState.UNWRAPPED) if isinstance(exc, ssl.CertificateError): msg = 'SSL handshake failed on verifying the certificate' |