Skip to content

Missing error handling in _PyEval_GetFrameLocals in ceval.c #118613

Description

@sobolevn

Bug report

Here's the problematic code:

cpython/Python/ceval.c

Lines 2497 to 2504 in d8d9491

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

What's wrong?

  1. PyDict_New() can return NULL, it is not checked
  2. Py_DECREF(locals); is only called on success, but not on error

Refs b034f14

I have a PR ready.

Linked PRs

Activity

  1. added
    type-bugAn unexpected behavior, bug, or error
    interpreter-core(Objects, Python, Grammar, and Parser dirs)
    on May 5, 2024
  2. self-assigned this
    on May 5, 2024
  3. added 2 commits that reference this issue on May 5, 2024
  4. added a commit that references this issue on May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

interpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions