diff options
author | Christian Heimes <christian@cheimes.de> | 2012-09-20 10:42:54 (GMT) |
---|---|---|
committer | Christian Heimes <christian@cheimes.de> | 2012-09-20 10:42:54 (GMT) |
commit | 63b38bbd1d36538dac8a21ba33117bd6800e58b4 (patch) | |
tree | 7bc3f61d077e5f135ed2c42873bd460408c591b6 /Modules | |
parent | f022aa502d1c3730f11a17e8534ea1ac91db4a8c (diff) | |
download | cpython-63b38bbd1d36538dac8a21ba33117bd6800e58b4.zip cpython-63b38bbd1d36538dac8a21ba33117bd6800e58b4.tar.gz cpython-63b38bbd1d36538dac8a21ba33117bd6800e58b4.tar.bz2 |
Issue #15977: Fix memory leak in Modules/_ssl.c when the function _set_npn_protocols() is called multiple times
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_ssl.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Modules/_ssl.c b/Modules/_ssl.c index 1104a4e..1516b87 100644 --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -1713,6 +1713,9 @@ context_new(PyTypeObject *type, PyObject *args, PyObject *kwds) return NULL; } self->ctx = ctx; +#ifdef OPENSSL_NPN_NEGOTIATED + self->npn_protocols = NULL; +#endif /* Defaults */ SSL_CTX_set_verify(self->ctx, SSL_VERIFY_NONE, NULL); SSL_CTX_set_options(self->ctx, @@ -1812,6 +1815,10 @@ _set_npn_protocols(PySSLContext *self, PyObject *args) if (!PyArg_ParseTuple(args, "y*:set_npn_protocols", &protos)) return NULL; + if (self->npn_protocols != NULL) { + PyMem_Free(self->npn_protocols); + } + self->npn_protocols = PyMem_Malloc(protos.len); if (self->npn_protocols == NULL) { PyBuffer_Release(&protos); |