]> 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 81ec44b13de140e18cd287d20b5d63ddb61465b9..d0161d10de97d38c83db8ca97e98617965dafda7 100644 (file)
--- 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.
 
index 751e26e39abbfa6f974f6478a73dd0c96b24932b..3fa2d6ac36f2ec1d3ef26e12b72e0f3eb789a24e 100644 (file)
@@ -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 */