python3/backport-0002-CVE-2023-40217.patch
2023-09-19 17:14:44 +08:00

39 lines
1.3 KiB
Diff

From 64f99350351bc46e016b2286f36ba7cd669b79e3 Mon Sep 17 00:00:00 2001
From: Victor Stinner <vstinner@python.org>
Date: Wed, 23 Aug 2023 07:26:01 +0200
Subject: [PATCH] gh-108342: Break ref cycle in SSLSocket._create() exc
(#108344)
Explicitly break a reference cycle when SSLSocket._create() raises an
exception. Clear the variable storing the exception, since the
exception traceback contains the variables and so creates a reference
cycle.
This test leak was introduced by the test added for the fix of #108310.
Reference: https://github.com/python/cpython/commit/64f99350351bc46e016b2286f36ba7cd669b79e3
Conflict:NA
---
Lib/ssl.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/Lib/ssl.py b/Lib/ssl.py
index 4142b8d..f7d42d7 100644
--- a/Lib/ssl.py
+++ b/Lib/ssl.py
@@ -878,7 +878,11 @@ class SSLSocket(socket):
self.close()
except OSError:
pass
- raise notconn_pre_handshake_data_error
+ try:
+ raise notconn_pre_handshake_data_error
+ finally:
+ # Explicitly break the reference cycle.
+ notconn_pre_handshake_data_error = None
else:
connected = True
--
2.27.0