Mercurial > cpython-lru_cache-weakref
diff Modules/socketmodule.c @ 20360:8a09c855f957 legacy-trunk
In newSSLObject(), initialize the various members of an SSLObject to NULL.
In SSL_dealloc(), free/dealloc them only if they're non-NULL.
Fixes some obvious core dumps, but not sure yet if there are more
semantics to the SSL calls that would affect the dealloc.
| author | Jeremy Hylton <jeremy@alum.mit.edu> |
|---|---|
| date | Wed, 10 Oct 2001 03:37:05 +0000 |
| parents | e191ceee672f |
| children | 7bcaca653388 |
line wrap: on
line diff
--- a/Modules/socketmodule.c Wed Oct 10 03:33:24 2001 +0000 +++ b/Modules/socketmodule.c Wed Oct 10 03:37:05 2001 +0000 @@ -2507,6 +2507,10 @@ } memset(self->server, '\0', sizeof(char) * 256); memset(self->issuer, '\0', sizeof(char) * 256); + self->server_cert = NULL; + self->ssl = NULL; + self->ctx = NULL; + self->Socket = NULL; self->ctx = SSL_CTX_new(SSLv23_method()); /* Set up context */ if (self->ctx == NULL) { @@ -2618,8 +2622,10 @@ { if (self->server_cert) /* Possible not to have one? */ X509_free (self->server_cert); - SSL_free(self->ssl); - SSL_CTX_free(self->ctx); + if (self->ssl) + SSL_free(self->ssl); + if (self->ctx) + SSL_CTX_free(self->ctx); Py_XDECREF(self->Socket); PyObject_Del(self); }
