Skip to content

Commit

Permalink
pythongh-118613: Fix error handling of _PyEval_GetFrameLocals in `c…
Browse files Browse the repository at this point in the history
…eval.c` (python#118614)
  • Loading branch information
sobolevn authored and SonicField committed May 8, 2024
1 parent 3268920 commit 86213f9
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -2496,17 +2496,21 @@ _PyEval_GetFrameLocals(void)

if (PyFrameLocalsProxy_Check(locals)) {
PyObject* ret = PyDict_New();
if (PyDict_Update(ret, locals)) {
if (ret == NULL) {
Py_DECREF(locals);
return NULL;
}
if (PyDict_Update(ret, locals) < 0) {
Py_DECREF(ret);
Py_DECREF(locals);
return NULL;
}
Py_DECREF(locals);
return ret;
} else if (PyMapping_Check(locals)) {
return locals;
}

return NULL;
assert(PyMapping_Check(locals));
return locals;
}

PyObject *
Expand Down

0 comments on commit 86213f9

Please sign in to comment.