Skip to content

Commit 88a7f66

Browse files
Fix possible NULL pointer dereference in _PyThread_CurrentFrames (GH-96584)
1 parent 30cc190 commit 88a7f66

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.

Python/pystate.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -1413,7 +1413,12 @@ _PyThread_CurrentFrames(void)
14131413
if (id == NULL) {
14141414
goto fail;
14151415
}
1416-
int stat = PyDict_SetItem(result, id, (PyObject *)_PyFrame_GetFrameObject(frame));
1416+
PyObject *frameobj = (PyObject *)_PyFrame_GetFrameObject(frame);
1417+
if (frameobj == NULL) {
1418+
Py_DECREF(id);
1419+
goto fail;
1420+
}
1421+
int stat = PyDict_SetItem(result, id, frameobj);
14171422
Py_DECREF(id);
14181423
if (stat < 0) {
14191424
goto fail;

0 commit comments

Comments
 (0)