]> granicus.if.org Git - python/commitdiff
Issue #13014: Fix a possible reference leak in SSLSocket.getpeercert().
authorAntoine Pitrou <solipsis@pitrou.net>
Wed, 15 Feb 2012 21:25:27 +0000 (22:25 +0100)
committerAntoine Pitrou <solipsis@pitrou.net>
Wed, 15 Feb 2012 21:25:27 +0000 (22:25 +0100)
Misc/NEWS
Modules/_ssl.c

index 474609e82bde312b77ec768b13c5d6545de1344b..41b7ad2c4b559898842a4bd3930f77980461dd3e 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -93,6 +93,8 @@ Core and Builtins
 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.
 
index eaf67c49a9a9880ae58c8511742c9e2f3dbe16a8..e692b5dfa6a6f21c0d08c0697bb845d0c0d75a0f 100644 (file)
@@ -644,15 +644,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 */