summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorKumar Aditya <59607654+kumaraditya303@users.noreply.github.com>2022-09-09 11:33:40 (GMT)
committerGitHub <noreply@github.com>2022-09-09 11:33:40 (GMT)
commit88a7f661ca02c0eb76b8f19234b8293b70f171e2 (patch)
tree76098ddbead29a28d0f936e8c30f7b29f334e23a /Python
parent30cc1901efa18180a83bf8402df9e1c10d877c49 (diff)
downloadcpython-88a7f661ca02c0eb76b8f19234b8293b70f171e2.zip
cpython-88a7f661ca02c0eb76b8f19234b8293b70f171e2.tar.gz
cpython-88a7f661ca02c0eb76b8f19234b8293b70f171e2.tar.bz2
Fix possible NULL pointer dereference in _PyThread_CurrentFrames (GH-96584)
Diffstat (limited to 'Python')
-rw-r--r--Python/pystate.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/Python/pystate.c b/Python/pystate.c
index 1c96f4f..a0d61d7 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -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;