]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix possible NULL pointer dereference in _PyThread_CurrentFrames (GH-96584)
authorKumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Fri, 9 Sep 2022 11:33:40 +0000 (17:03 +0530)
committerGitHub <noreply@github.com>
Fri, 9 Sep 2022 11:33:40 +0000 (12:33 +0100)
Misc/NEWS.d/next/Core and Builtins/2022-09-05-15-07-25.gh-issue-96582.HEsL5s.rst [new file with mode: 0644]
Python/pystate.c

diff --git a/Misc/NEWS.d/next/Core and Builtins/2022-09-05-15-07-25.gh-issue-96582.HEsL5s.rst b/Misc/NEWS.d/next/Core and Builtins/2022-09-05-15-07-25.gh-issue-96582.HEsL5s.rst
new file mode 100644 (file)
index 0000000..162f7ba
--- /dev/null
@@ -0,0 +1 @@
+Fix possible ``NULL`` pointer dereference in ``_PyThread_CurrentFrames``. Patch by Kumar Aditya.
index 1c96f4f75f29a6d28ccbc42acab5de22e81d923f..a0d61d7ebb3be988fbd79a5a54c6a652c473a4b7 100644 (file)
@@ -1413,7 +1413,12 @@ _PyThread_CurrentFrames(void)
             if (id == NULL) {
                 goto fail;
             }
-            int stat = PyDict_SetItem(result, id, (PyObject *)_PyFrame_GetFrameObject(frame));
+            PyObject *frameobj = (PyObject *)_PyFrame_GetFrameObject(frame);
+            if (frameobj == NULL) {
+                Py_DECREF(id);
+                goto fail;
+            }
+            int stat = PyDict_SetItem(result, id, frameobj);
             Py_DECREF(id);
             if (stat < 0) {
                 goto fail;