summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2020-07-08 04:40:18 (GMT)
committerGitHub <noreply@github.com>2020-07-08 04:40:18 (GMT)
commit1d1c5743400bdf384ec83eb6ba5b39a355d121e3 (patch)
tree9713d4ee141671dc166a09d7da67df6f8e1d2f46
parent366cfc65f26b159e44ee30917ab35afe59f8339f (diff)
downloadcpython-1d1c5743400bdf384ec83eb6ba5b39a355d121e3.zip
cpython-1d1c5743400bdf384ec83eb6ba5b39a355d121e3.tar.gz
cpython-1d1c5743400bdf384ec83eb6ba5b39a355d121e3.tar.bz2
closes bpo-41235: Fix the error handling in SSLContext.load_dh_params() (GH-21385)
(cherry picked from commit aebc0495572c5bb85d2bd97d27cf93ab038b5a6a) Co-authored-by: Zackery Spytz <zspytz@gmail.com>
-rw-r--r--Misc/NEWS.d/next/Library/2020-07-07-21-56-26.bpo-41235.H2csMU.rst1
-rw-r--r--Modules/_ssl.c6
2 files changed, 5 insertions, 2 deletions
diff --git a/Misc/NEWS.d/next/Library/2020-07-07-21-56-26.bpo-41235.H2csMU.rst b/Misc/NEWS.d/next/Library/2020-07-07-21-56-26.bpo-41235.H2csMU.rst
new file mode 100644
index 0000000..c55275b
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-07-07-21-56-26.bpo-41235.H2csMU.rst
@@ -0,0 +1 @@
+Fix the error handling in :meth:`ssl.SSLContext.load_dh_params`.
diff --git a/Modules/_ssl.c b/Modules/_ssl.c
index 5e82fe4..5806417 100644
--- a/Modules/_ssl.c
+++ b/Modules/_ssl.c
@@ -4309,8 +4309,10 @@ _ssl__SSLContext_load_dh_params(PySSLContext *self, PyObject *filepath)
}
return NULL;
}
- if (SSL_CTX_set_tmp_dh(self->ctx, dh) == 0)
- _setSSLError(NULL, 0, __FILE__, __LINE__);
+ if (!SSL_CTX_set_tmp_dh(self->ctx, dh)) {
+ DH_free(dh);
+ return _setSSLError(NULL, 0, __FILE__, __LINE__);
+ }
DH_free(dh);
Py_RETURN_NONE;
}