Skip to content

Missing error handling in _PyEval_GetFrameLocals in ceval.c #118613

Closed
@sobolevn

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

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