Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing error handling in _PyEval_GetFrameLocals in ceval.c #118613

Closed
sobolevn opened this issue May 5, 2024 · 0 comments
Closed

Missing error handling in _PyEval_GetFrameLocals in ceval.c #118613

sobolevn opened this issue May 5, 2024 · 0 comments
Assignees
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@sobolevn
Copy link
Member

sobolevn commented May 5, 2024

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

@sobolevn sobolevn added type-bug An unexpected behavior, bug, or error interpreter-core (Objects, Python, Grammar, and Parser dirs) labels May 5, 2024
@sobolevn sobolevn self-assigned this May 5, 2024
sobolevn added a commit to sobolevn/cpython that referenced this issue May 5, 2024
@sobolevn sobolevn closed this as completed May 6, 2024
SonicField pushed a commit to SonicField/cpython that referenced this issue May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant