Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
--- /dev/null
+Fixes a possible ``NULL`` pointer dereference in :mod:`ssl`.
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;
}