Skip to content

Commit c563b89

Browse files
Fix possible NULL pointer dereference in _PyThread_CurrentFrames (GH-96584)
(cherry picked from commit 88a7f66) Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
1 parent fecda02 commit c563b89

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix possible ``NULL`` pointer dereference in ``_PyThread_CurrentFrames``. Patch by Kumar Aditya.

Diff for: Python/pystate.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -1398,7 +1398,12 @@ _PyThread_CurrentFrames(void)
13981398
if (id == NULL) {
13991399
goto fail;
14001400
}
1401-
int stat = PyDict_SetItem(result, id, (PyObject *)_PyFrame_GetFrameObject(frame));
1401+
PyObject *frameobj = (PyObject *)_PyFrame_GetFrameObject(frame);
1402+
if (frameobj == NULL) {
1403+
Py_DECREF(id);
1404+
goto fail;
1405+
}
1406+
int stat = PyDict_SetItem(result, id, frameobj);
14021407
Py_DECREF(id);
14031408
if (stat < 0) {
14041409
goto fail;

0 commit comments

Comments
 (0)