]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-126106: Fix `NULL` possible derefrence in `Modules/_ssl.c` (GH-126111)...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 29 Oct 2024 09:26:28 +0000 (10:26 +0100)
committerGitHub <noreply@github.com>
Tue, 29 Oct 2024 09:26:28 +0000 (09:26 +0000)
gh-126106: Fix `NULL` possible derefrence in `Modules/_ssl.c` (GH-126111)
(cherry picked from commit a64a1c920660b0c1e4dd5a9573004cd527e15184)

Co-authored-by: sobolevn <mail@sobolevn.me>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Misc/NEWS.d/next/Library/2024-10-29-10-58-52.gh-issue-126106.rlF798.rst [new file with mode: 0644]
Modules/_ssl.c

diff --git a/Misc/NEWS.d/next/Library/2024-10-29-10-58-52.gh-issue-126106.rlF798.rst b/Misc/NEWS.d/next/Library/2024-10-29-10-58-52.gh-issue-126106.rlF798.rst
new file mode 100644 (file)
index 0000000..de98900
--- /dev/null
@@ -0,0 +1 @@
+Fixes a possible ``NULL`` pointer dereference in :mod:`ssl`.
index 7fcb79fec9f74e344369d7e04dfbe5d07301f29e..35e4ce7af50fc69ccff64ae18b95dc955b4c2f88 100644 (file)
@@ -4951,14 +4951,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;
     }