Skip to content

Commit bc9ae4a

Browse files
miss-islingtonsobolevnpicnixz
authored
[3.12] gh-126106: Fix NULL possible derefrence in Modules/_ssl.c (GH-126111) (#126117)
gh-126106: Fix `NULL` possible derefrence in `Modules/_ssl.c` (GH-126111) (cherry picked from commit a64a1c9) Co-authored-by: sobolevn <[email protected]> Co-authored-by: Bénédikt Tran <[email protected]>
1 parent a8472fd commit bc9ae4a

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixes a possible ``NULL`` pointer dereference in :mod:`ssl`.

Modules/_ssl.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4951,14 +4951,14 @@ PySSLSession_dealloc(PySSLSession *self)
49514951
static PyObject *
49524952
PySSLSession_richcompare(PyObject *left, PyObject *right, int op)
49534953
{
4954-
int result;
4955-
PyTypeObject *sesstype = ((PySSLSession*)left)->ctx->state->PySSLSession_Type;
4956-
49574954
if (left == NULL || right == NULL) {
49584955
PyErr_BadInternalCall();
49594956
return NULL;
49604957
}
49614958

4959+
int result;
4960+
PyTypeObject *sesstype = ((PySSLSession*)left)->ctx->state->PySSLSession_Type;
4961+
49624962
if (!Py_IS_TYPE(left, sesstype) || !Py_IS_TYPE(right, sesstype)) {
49634963
Py_RETURN_NOTIMPLEMENTED;
49644964
}

0 commit comments

Comments
 (0)