https://github.com/python/cpython/commit/bc9ae4a1caf053a264c6f6623755a5f39da76dc7
commit: bc9ae4a1caf053a264c6f6623755a5f39da76dc7
branch: 3.12
author: Miss Islington (bot) <[email protected]>
committer: sobolevn <[email protected]>
date: 2024-10-29T09:26:28Z
summary:

[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 a64a1c920660b0c1e4dd5a9573004cd527e15184)

Co-authored-by: sobolevn <[email protected]>
Co-authored-by: Bénédikt Tran <[email protected]>

files:
A Misc/NEWS.d/next/Library/2024-10-29-10-58-52.gh-issue-126106.rlF798.rst
M 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
index 00000000000000..de989007b4c35a
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2024-10-29-10-58-52.gh-issue-126106.rlF798.rst
@@ -0,0 +1 @@
+Fixes a possible ``NULL`` pointer dereference in :mod:`ssl`.
diff --git a/Modules/_ssl.c b/Modules/_ssl.c
index 7fcb79fec9f74e..35e4ce7af50fc6 100644
--- a/Modules/_ssl.c
+++ b/Modules/_ssl.c
@@ -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;
     }

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to