Skip to content

Commit 1d1c574

Browse files
closes bpo-41235: Fix the error handling in SSLContext.load_dh_params() (GH-21385)
(cherry picked from commit aebc049) Co-authored-by: Zackery Spytz <[email protected]>
1 parent 366cfc6 commit 1d1c574

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix the error handling in :meth:`ssl.SSLContext.load_dh_params`.

Modules/_ssl.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4309,8 +4309,10 @@ _ssl__SSLContext_load_dh_params(PySSLContext *self, PyObject *filepath)
43094309
}
43104310
return NULL;
43114311
}
4312-
if (SSL_CTX_set_tmp_dh(self->ctx, dh) == 0)
4313-
_setSSLError(NULL, 0, __FILE__, __LINE__);
4312+
if (!SSL_CTX_set_tmp_dh(self->ctx, dh)) {
4313+
DH_free(dh);
4314+
return _setSSLError(NULL, 0, __FILE__, __LINE__);
4315+
}
43144316
DH_free(dh);
43154317
Py_RETURN_NONE;
43164318
}

0 commit comments

Comments
 (0)