mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
[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 80aa7b3688
)
Co-authored-by: Jamie Phan <jamie@ordinarylab.dev>
This commit is contained in:
parent
21b68a1198
commit
0ee6fbaab6
3 changed files with 8 additions and 0 deletions
|
@ -235,6 +235,10 @@ class BaseSelectorEventLoop(base_events.BaseEventLoop):
|
||||||
await waiter
|
await waiter
|
||||||
except BaseException:
|
except BaseException:
|
||||||
transport.close()
|
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
|
raise
|
||||||
# It's now up to the protocol to handle the connection.
|
# It's now up to the protocol to handle the connection.
|
||||||
|
|
||||||
|
|
|
@ -579,6 +579,7 @@ class SSLProtocol(protocols.BufferedProtocol):
|
||||||
|
|
||||||
peercert = sslobj.getpeercert()
|
peercert = sslobj.getpeercert()
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
|
handshake_exc = None
|
||||||
self._set_state(SSLProtocolState.UNWRAPPED)
|
self._set_state(SSLProtocolState.UNWRAPPED)
|
||||||
if isinstance(exc, ssl.CertificateError):
|
if isinstance(exc, ssl.CertificateError):
|
||||||
msg = 'SSL handshake failed on verifying the certificate'
|
msg = 'SSL handshake failed on verifying the certificate'
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
Fix a reference leak in
|
||||||
|
:class:`asyncio.selector_events.BaseSelectorEventLoop` when SSL handshakes
|
||||||
|
fail. Patch contributed by Jamie Phan.
|
Loading…
Add table
Add a link
Reference in a new issue