gh-126106: Fix `NULL` possible derefrence in `Modules/_ssl.c` (#126111)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
This commit is contained in:
sobolevn 2024-10-29 12:03:18 +03:00 committed by GitHub
parent 9b14083497
commit a64a1c9206
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 3 deletions

View File

@ -0,0 +1 @@
Fixes a possible ``NULL`` pointer dereference in :mod:`ssl`.

View File

@ -5424,14 +5424,14 @@ PySSLSession_dealloc(PySSLSession *self)
static PyObject *
PySSLSession_richcompare(PyObject *left, PyObject *right, int op)
{
int result;
PyTypeObject *sesstype = ((PySSLSession*)left)->ctx->state->PySSLSession_Type;
if (left == NULL || right == NULL) {
PyErr_BadInternalCall();
return NULL;
}
int result;
PyTypeObject *sesstype = ((PySSLSession*)left)->ctx->state->PySSLSession_Type;
if (!Py_IS_TYPE(left, sesstype) || !Py_IS_TYPE(right, sesstype)) {
Py_RETURN_NOTIMPLEMENTED;
}