[3.5] bpo-30594: Fixed refcounting in newPySSLSocket (GH-1992) (#1993) · python/cpython@54ba41e (original) (raw)

Original file line number Diff line number Diff line change
@@ -570,6 +570,7 @@ newPySSLSocket(PySSLContext *sslctx, PySocketSockObject *sock,
570 570 self->ssl = NULL;
571 571 self->Socket = NULL;
572 572 self->ctx = sslctx;
573 +Py_INCREF(sslctx);
573 574 self->shutdown_seen_zero = 0;
574 575 self->handshake_done = 0;
575 576 self->owner = NULL;
@@ -584,8 +585,6 @@ newPySSLSocket(PySSLContext *sslctx, PySocketSockObject *sock,
584 585 self->server_hostname = hostname;
585 586 }
586 587
587 -Py_INCREF(sslctx);
588 -
589 588 /* Make sure the SSL error state is initialized */
590 589 (void) ERR_get_state();
591 590 ERR_clear_error();