Mercurial > cpython-lru_cache-weakref
changeset 79063:2bdc8c8ea42e
Issue #15977: Fix memory leak in Modules/_ssl.c when the function _set_npn_protocols() is called multiple times
| author | Christian Heimes <christian@cheimes.de> |
|---|---|
| date | Thu, 20 Sep 2012 12:42:54 +0200 |
| parents | c6892ce7e56f |
| children | dcced3bd22fe |
| files | Misc/NEWS Modules/_ssl.c |
| diffstat | 2 files changed, 10 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/Misc/NEWS Mon Sep 17 09:01:03 2012 +0200 +++ b/Misc/NEWS Thu Sep 20 12:42:54 2012 +0200 @@ -68,6 +68,9 @@ Extension Modules ----------------- +- Issue #15977: Fix memory leak in Modules/_ssl.c when the function + _set_npn_protocols() is called multiple times, thanks to Daniel Sommermann. + Tests -----
--- a/Modules/_ssl.c Mon Sep 17 09:01:03 2012 +0200 +++ b/Modules/_ssl.c Thu Sep 20 12:42:54 2012 +0200 @@ -1713,6 +1713,9 @@ 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 @@ 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);
