[Python-checkins] bpo-41252: Fix incorrect refcounting in _ssl.c's _servername_callback() (GH-21407)
Zackery Spytz
webhook-mailer at python.org
Thu Jul 9 06:00:30 EDT 2020
https://github.com/python/cpython/commit/ee96f32ca24779656d3c8736d26671fc3689f0a3
commit: ee96f32ca24779656d3c8736d26671fc3689f0a3
branch: master
author: Zackery Spytz <zspytz at gmail.com>
committer: GitHub <noreply at github.com>
date: 2020-07-09T03:00:21-07:00
summary:
bpo-41252: Fix incorrect refcounting in _ssl.c's _servername_callback() (GH-21407)
files:
A Misc/NEWS.d/next/Core and Builtins/2020-07-08-21-55-23.bpo-41252.nBWL-Y.rst
M Modules/_ssl.c
diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-07-08-21-55-23.bpo-41252.nBWL-Y.rst b/Misc/NEWS.d/next/Core and Builtins/2020-07-08-21-55-23.bpo-41252.nBWL-Y.rst
new file mode 100644
index 0000000000000..65f3189c83ec6
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2020-07-08-21-55-23.bpo-41252.nBWL-Y.rst
@@ -0,0 +1 @@
+Fix incorrect refcounting in _ssl.c's ``_servername_callback()``.
diff --git a/Modules/_ssl.c b/Modules/_ssl.c
index 58064178a1a34..a8c339d9f3334 100644
--- a/Modules/_ssl.c
+++ b/Modules/_ssl.c
@@ -4545,11 +4545,12 @@ _servername_callback(SSL *s, int *al, void *args)
* back into a str object, but still as an A-label (bpo-28414)
*/
servername_str = PyUnicode_FromEncodedObject(servername_bytes, "ascii", NULL);
- Py_DECREF(servername_bytes);
if (servername_str == NULL) {
PyErr_WriteUnraisable(servername_bytes);
+ Py_DECREF(servername_bytes);
goto error;
}
+ Py_DECREF(servername_bytes);
result = PyObject_CallFunctionObjArgs(
ssl_ctx->set_sni_cb, ssl_socket, servername_str,
ssl_ctx, NULL);
More information about the Python-checkins
mailing list