Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a853c47

Browse files
committed
merge 3.5 (#27773)
2 parents cc2e80b + 81b9ecd commit a853c47

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ Library
9090

9191
- Issue #6422: Add autorange method to timeit.Timer objects.
9292

93+
- Issue #27773: Correct some memory management errors server_hostname in _ssl.wrap_socket().
94+
9395
- Issue #26750: unittest.mock.create_autospec() now works properly for
9496
subclasses of property() and other data descriptors. Removes the never
9597
publicly used, never documented unittest.mock.DescriptorTypes tuple.

Modules/_ssl.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,6 @@ newPySSLSocket(PySSLContext *sslctx, PySocketSockObject *sock,
487487
{
488488
PySSLSocket *self;
489489
SSL_CTX *ctx = sslctx->ctx;
490-
PyObject *hostname;
491490
long mode;
492491

493492
self = PyObject_New(PySSLSocket, &PySSLSocket_Type);
@@ -501,16 +500,16 @@ newPySSLSocket(PySSLContext *sslctx, PySocketSockObject *sock,
501500
self->shutdown_seen_zero = 0;
502501
self->handshake_done = 0;
503502
self->owner = NULL;
503+
self->server_hostname = NULL;
504504
if (server_hostname != NULL) {
505-
hostname = PyUnicode_Decode(server_hostname, strlen(server_hostname),
506-
"idna", "strict");
505+
PyObject *hostname = PyUnicode_Decode(server_hostname, strlen(server_hostname),
506+
"idna", "strict");
507507
if (hostname == NULL) {
508508
Py_DECREF(self);
509509
return NULL;
510510
}
511511
self->server_hostname = hostname;
512-
} else
513-
self->server_hostname = NULL;
512+
}
514513

515514
Py_INCREF(sslctx);
516515

@@ -563,7 +562,6 @@ newPySSLSocket(PySSLContext *sslctx, PySocketSockObject *sock,
563562
self->Socket = PyWeakref_NewRef((PyObject *) sock, NULL);
564563
if (self->Socket == NULL) {
565564
Py_DECREF(self);
566-
Py_XDECREF(self->server_hostname);
567565
return NULL;
568566
}
569567
}

0 commit comments

Comments
 (0)