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

Original file line number Diff line number Diff line change
@@ -596,6 +596,7 @@ newPySSLSocket(PySSLContext *sslctx, PySocketSockObject *sock,
596 596 self->ssl = NULL;
597 597 self->Socket = NULL;
598 598 self->ctx = sslctx;
599 +Py_INCREF(sslctx);
599 600 self->shutdown_seen_zero = 0;
600 601 self->owner = NULL;
601 602 self->server_hostname = NULL;
@@ -609,8 +610,6 @@ newPySSLSocket(PySSLContext *sslctx, PySocketSockObject *sock,
609 610 self->server_hostname = hostname;
610 611 }
611 612
612 -Py_INCREF(sslctx);
613 -
614 613 /* Make sure the SSL error state is initialized */
615 614 (void) ERR_get_state();
616 615 ERR_clear_error();