diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-02-15 21:28:21 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-02-15 21:28:21 (GMT) |
commit | 04d4ee4e561724a111cf5cba7be399a2d9199dcb (patch) | |
tree | f7ff32057f01d5e0bcce5531f141b9403ca9b06b /Modules/_ssl.c | |
parent | be2cf338e9baef1f2479a33a8c7b5552bf9bd86f (diff) | |
parent | 2f5a163dfc76d53b5ecd04ff19c4d15761d106a7 (diff) | |
download | cpython-04d4ee4e561724a111cf5cba7be399a2d9199dcb.zip cpython-04d4ee4e561724a111cf5cba7be399a2d9199dcb.tar.gz cpython-04d4ee4e561724a111cf5cba7be399a2d9199dcb.tar.bz2 |
Issue #13014: Fix a possible reference leak in SSLSocket.getpeercert().
Diffstat (limited to 'Modules/_ssl.c')
-rw-r--r-- | Modules/_ssl.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/Modules/_ssl.c b/Modules/_ssl.c index 3e2e264..97fc07f 100644 --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -547,15 +547,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 */ |