Co-authored-by: Ramin Farajpour Cami <ramin.blackhat@gmail.com>
--- /dev/null
+Fixed a use-after-free in :mod:`ssl` when ``SSL_new()`` returns NULL in
+``newPySSLSocket()``. The error was reported via a dangling pointer after the
+object had already been freed.
self->ssl = SSL_new(ctx);
PySSL_END_ALLOW_THREADS
if (self->ssl == NULL) {
+ _setSSLError(get_state_ctx(sslctx), NULL, 0, __FILE__, __LINE__);
Py_DECREF(self);
- _setSSLError(get_state_ctx(self), NULL, 0, __FILE__, __LINE__);
return NULL;
}
/* bpo43522 and OpenSSL < 1.1.1l: copy hostflags manually */