Kaydet (Commit) 65ece7ca authored tarafından Nathaniel J. Smith's avatar Nathaniel J. Smith Kaydeden (comit) Serhiy Storchaka

bpo-30594: Fixed refcounting in newPySSLSocket (#1992)

If pass a server_hostname= that fails IDNA decoding to SSLContext.wrap_socket or SSLContext.wrap_bio, then the SSLContext object had a spurious Py_DECREF called on it, eventually leading to segfaults.
üst 0ecdc525
......@@ -596,6 +596,7 @@ newPySSLSocket(PySSLContext *sslctx, PySocketSockObject *sock,
self->ssl = NULL;
self->Socket = NULL;
self->ctx = sslctx;
Py_INCREF(sslctx);
self->shutdown_seen_zero = 0;
self->owner = NULL;
self->server_hostname = NULL;
......@@ -609,8 +610,6 @@ newPySSLSocket(PySSLContext *sslctx, PySocketSockObject *sock,
self->server_hostname = hostname;
}
Py_INCREF(sslctx);
/* Make sure the SSL error state is initialized */
(void) ERR_get_state();
ERR_clear_error();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment