bpo-30594: Fixed refcounting in newPySSLSocket (#1992) · python/cpython@65ece7c

Original file line numberDiff line numberDiff line change

@@ -596,6 +596,7 @@ newPySSLSocket(PySSLContext *sslctx, PySocketSockObject *sock,

596596

self->ssl = NULL;

597597

self->Socket = NULL;

598598

self->ctx = sslctx;

599+

Py_INCREF(sslctx);

599600

self->shutdown_seen_zero = 0;

600601

self->owner = NULL;

601602

self->server_hostname = NULL;

@@ -609,8 +610,6 @@ newPySSLSocket(PySSLContext *sslctx, PySocketSockObject *sock,

609610

self->server_hostname = hostname;

610611

}

611612
612-

Py_INCREF(sslctx);

613-
614613

/* Make sure the SSL error state is initialized */

615614

(void) ERR_get_state();

616615

ERR_clear_error();