diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-09-10 11:12:46 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-10 11:12:46 (GMT) |
commit | c563b892618d1859ce0191c2e8097df4b3469f9a (patch) | |
tree | e45dac098b12583f57bc55a92821f6e707f4d396 | |
parent | fecda02eb6ae3723311c2da67bb5dd48797cb8dd (diff) | |
download | cpython-c563b892618d1859ce0191c2e8097df4b3469f9a.zip cpython-c563b892618d1859ce0191c2e8097df4b3469f9a.tar.gz cpython-c563b892618d1859ce0191c2e8097df4b3469f9a.tar.bz2 |
Fix possible NULL pointer dereference in _PyThread_CurrentFrames (GH-96584)
(cherry picked from commit 88a7f661ca02c0eb76b8f19234b8293b70f171e2)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
-rw-r--r-- | Misc/NEWS.d/next/Core and Builtins/2022-09-05-15-07-25.gh-issue-96582.HEsL5s.rst | 1 | ||||
-rw-r--r-- | Python/pystate.c | 7 |
2 files changed, 7 insertions, 1 deletions
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 index 0000000..162f7ba --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2022-09-05-15-07-25.gh-issue-96582.HEsL5s.rst @@ -0,0 +1 @@ +Fix possible ``NULL`` pointer dereference in ``_PyThread_CurrentFrames``. Patch by Kumar Aditya. diff --git a/Python/pystate.c b/Python/pystate.c index 3a8140b..12ebbe3 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -1398,7 +1398,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; |