diff options
author | Benjamin Peterson <benjamin@python.org> | 2016-08-16 04:55:37 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2016-08-16 04:55:37 (GMT) |
commit | 81b9ecd2a3338cad109c2827af423867e46c6808 (patch) | |
tree | a30325609a54e0dedf4593a6d02e7c9157d2edec /Modules | |
parent | b1c6bdc76a1ac7bc40850f75dbc2dff0b361ee3d (diff) | |
download | cpython-81b9ecd2a3338cad109c2827af423867e46c6808.zip cpython-81b9ecd2a3338cad109c2827af423867e46c6808.tar.gz cpython-81b9ecd2a3338cad109c2827af423867e46c6808.tar.bz2 |
fix corner cases in the management of server_hostname (closes #27773)
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_ssl.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/Modules/_ssl.c b/Modules/_ssl.c index c21c0f8..391034e 100644 --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -487,7 +487,6 @@ newPySSLSocket(PySSLContext *sslctx, PySocketSockObject *sock, { PySSLSocket *self; SSL_CTX *ctx = sslctx->ctx; - PyObject *hostname; long mode; self = PyObject_New(PySSLSocket, &PySSLSocket_Type); @@ -501,16 +500,16 @@ newPySSLSocket(PySSLContext *sslctx, PySocketSockObject *sock, 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 @@ newPySSLSocket(PySSLContext *sslctx, PySocketSockObject *sock, self->Socket = PyWeakref_NewRef((PyObject *) sock, NULL); if (self->Socket == NULL) { Py_DECREF(self); - Py_XDECREF(self->server_hostname); return NULL; } } |