[Python-checkins] cpython (2.7): Issue #13014: Fix a possible reference leak in SSLSocket.getpeercert().

antoine.pitrou python-checkins at python.org
Wed Feb 15 22:34:41 CET 2012


http://hg.python.org/cpython/rev/111dcae41ff7
changeset:   74965:111dcae41ff7
branch:      2.7
parent:      74956:db1c52aa4d2a
user:        Antoine Pitrou <solipsis at pitrou.net>
date:        Wed Feb 15 22:25:27 2012 +0100
summary:
  Issue #13014: Fix a possible reference leak in SSLSocket.getpeercert().

files:
  Misc/NEWS      |   2 ++
  Modules/_ssl.c |  23 ++++++++++++++---------
  2 files changed, 16 insertions(+), 9 deletions(-)


diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -93,6 +93,8 @@
 Library
 -------
 
+- Issue #13014: Fix a possible reference leak in SSLSocket.getpeercert().
+
 - Issue #13987: HTMLParser is now able to handle EOFs in the middle of a
   construct and malformed start tags.
 
diff --git a/Modules/_ssl.c b/Modules/_ssl.c
--- a/Modules/_ssl.c
+++ b/Modules/_ssl.c
@@ -644,15 +644,20 @@
             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 */

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list