Skip to content

Commit c8b599f

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 730bce3 commit c8b599f

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
@@ -4312,8 +4312,10 @@ _ssl__SSLContext_load_dh_params(PySSLContext *self, PyObject *filepath)
43124312
}
43134313
return NULL;
43144314
}
4315-
if (SSL_CTX_set_tmp_dh(self->ctx, dh) == 0)
4316-
_setSSLError(NULL, 0, __FILE__, __LINE__);
4315+
if (!SSL_CTX_set_tmp_dh(self->ctx, dh)) {
4316+
DH_free(dh);
4317+
return _setSSLError(NULL, 0, __FILE__, __LINE__);
4318+
}
43174319
DH_free(dh);
43184320
Py_RETURN_NONE;
43194321
}

0 commit comments

Comments
 (0)