diff options
author | Gregory P. Smith <greg@krypto.org> | 2020-06-20 19:15:03 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-20 19:15:03 (GMT) |
commit | eb0d5c38de7f970d8cd8524f4163d831c7720f51 (patch) | |
tree | 2b290599e017315fe26831c544201067bc618117 /Modules | |
parent | 314858e2763e76e77029ea0b691d749c32939087 (diff) | |
download | cpython-eb0d5c38de7f970d8cd8524f4163d831c7720f51.zip cpython-eb0d5c38de7f970d8cd8524f4163d831c7720f51.tar.gz cpython-eb0d5c38de7f970d8cd8524f4163d831c7720f51.tar.bz2 |
bpo-41056: Fix a NULL pointer dereference on MemoryError within the ssl module. (GH-21009)
Detected by Coverity.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_ssl/debughelpers.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Modules/_ssl/debughelpers.c b/Modules/_ssl/debughelpers.c index 858b3d7..b840da2 100644 --- a/Modules/_ssl/debughelpers.c +++ b/Modules/_ssl/debughelpers.c @@ -125,6 +125,12 @@ _PySSL_keylog_callback(const SSL *ssl, const char *line) threadstate = PyGILState_Ensure(); + ssl_obj = (PySSLSocket *)SSL_get_app_data(ssl); + assert(PySSLSocket_Check(ssl_obj)); + if (ssl_obj->ctx->keylog_bio == NULL) { + return; + } + /* Allocate a static lock to synchronize writes to keylog file. * The lock is neither released on exit nor on fork(). The lock is * also shared between all SSLContexts although contexts may write to @@ -141,12 +147,6 @@ _PySSL_keylog_callback(const SSL *ssl, const char *line) } } - ssl_obj = (PySSLSocket *)SSL_get_app_data(ssl); - assert(PySSLSocket_Check(ssl_obj)); - if (ssl_obj->ctx->keylog_bio == NULL) { - return; - } - PySSL_BEGIN_ALLOW_THREADS PyThread_acquire_lock(lock, 1); res = BIO_printf(ssl_obj->ctx->keylog_bio, "%s\n", line); |