Fix possible NULL pointer dereference in _PyThread_CurrentFrames (GH-96584)

(cherry picked from commit 88a7f661ca)

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
This commit is contained in:
Miss Islington (bot) 2022-09-10 04:12:46 -07:00 committed by GitHub
parent fecda02eb6
commit c563b89261
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View file

@ -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;