changeset: 102687:a8cd67e80ed3 parent: 102685:0052694ec55d parent: 102686:98c86d5a6655 user: Benjamin Peterson date: Mon Aug 15 21:56:11 2016 -0700 files: Misc/NEWS Modules/_ssl.c description: merge 3.5 (#27773) diff -r 0052694ec55d -r a8cd67e80ed3 Misc/NEWS --- a/Misc/NEWS Mon Aug 15 21:44:06 2016 -0700 +++ b/Misc/NEWS Mon Aug 15 21:56:11 2016 -0700 @@ -90,6 +90,8 @@ - Issue #6422: Add autorange method to timeit.Timer objects. +- Issue #27773: Correct some memory management errors server_hostname in _ssl.wrap_socket(). + - Issue #26750: unittest.mock.create_autospec() now works properly for subclasses of property() and other data descriptors. Removes the never publicly used, never documented unittest.mock.DescriptorTypes tuple. diff -r 0052694ec55d -r a8cd67e80ed3 Modules/_ssl.c --- a/Modules/_ssl.c Mon Aug 15 21:44:06 2016 -0700 +++ b/Modules/_ssl.c Mon Aug 15 21:56:11 2016 -0700 @@ -487,7 +487,6 @@ { PySSLSocket *self; SSL_CTX *ctx = sslctx->ctx; - PyObject *hostname; long mode; self = PyObject_New(PySSLSocket, &PySSLSocket_Type); @@ -501,16 +500,16 @@ self->shutdown_seen_zero = 0; self->handshake_done = 0; self->owner = NULL; + self->server_hostname = NULL; if (server_hostname != NULL) { - hostname = PyUnicode_Decode(server_hostname, strlen(server_hostname), - "idna", "strict"); + PyObject *hostname = PyUnicode_Decode(server_hostname, strlen(server_hostname), + "idna", "strict"); if (hostname == NULL) { Py_DECREF(self); return NULL; } self->server_hostname = hostname; - } else - self->server_hostname = NULL; + } Py_INCREF(sslctx); @@ -563,7 +562,6 @@ self->Socket = PyWeakref_NewRef((PyObject *) sock, NULL); if (self->Socket == NULL) { Py_DECREF(self); - Py_XDECREF(self->server_hostname); return NULL; } }