summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2012-02-15 21:25:27 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2012-02-15 21:25:27 (GMT)
commit2f5a163dfc76d53b5ecd04ff19c4d15761d106a7 (patch)
treebfdc895089c727da59b06f7b2a2fe1e464e0b8c1
parent1ca93954e17e4f6f1230306997badbda3e5c68bc (diff)
downloadcpython-2f5a163dfc76d53b5ecd04ff19c4d15761d106a7.zip
cpython-2f5a163dfc76d53b5ecd04ff19c4d15761d106a7.tar.gz
cpython-2f5a163dfc76d53b5ecd04ff19c4d15761d106a7.tar.bz2
Issue #13014: Fix a possible reference leak in SSLSocket.getpeercert().
-rw-r--r--Misc/NEWS2
-rw-r--r--Modules/_ssl.c23
2 files changed, 16 insertions, 9 deletions
diff --git a/Misc/NEWS b/Misc/NEWS
index 81ec44b..d0161d1 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -116,6 +116,8 @@ Core and Builtins
Library
-------
+- Issue #13014: Fix a possible reference leak in SSLSocket.getpeercert().
+
- Issue #13015: Fix a possible reference leak in defaultdict.__repr__.
Patch by Suman Saha.
diff --git a/Modules/_ssl.c b/Modules/_ssl.c
index 751e26e..3fa2d6a 100644
--- a/Modules/_ssl.c
+++ b/Modules/_ssl.c
@@ -519,15 +519,20 @@ _create_tuple_for_X509_NAME (X509_NAME *xname)
goto fail1;
}
/* now, there's typically a dangling RDN */
- if ((rdn != NULL) && (PyList_Size(rdn) > 0)) {
- rdnt = PyList_AsTuple(rdn);
- Py_DECREF(rdn);
- if (rdnt == NULL)
- goto fail0;
- retcode = PyList_Append(dn, rdnt);
- Py_DECREF(rdnt);
- if (retcode < 0)
- goto fail0;
+ if (rdn != NULL) {
+ if (PyList_GET_SIZE(rdn) > 0) {
+ rdnt = PyList_AsTuple(rdn);
+ Py_DECREF(rdn);
+ if (rdnt == NULL)
+ goto fail0;
+ retcode = PyList_Append(dn, rdnt);
+ Py_DECREF(rdnt);
+ if (retcode < 0)
+ goto fail0;
+ }
+ else {
+ Py_DECREF(rdn);
+ }
}
/* convert list to tuple */