Skip to content

Missing decref in error handling of func_get_annotation_dict #122229

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

Closed
sobolevn opened this issue Jul 24, 2024 · 0 comments
Closed

Missing decref in error handling of func_get_annotation_dict #122229

sobolevn opened this issue Jul 24, 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 Jul 24, 2024

Bug report

Here:

PyObject *ann_dict = PyDict_New();
if (ann_dict == NULL) {
return NULL;
}
assert(PyTuple_GET_SIZE(ann_tuple) % 2 == 0);
for (Py_ssize_t i = 0; i < PyTuple_GET_SIZE(ann_tuple); i += 2) {
int err = PyDict_SetItem(ann_dict,
PyTuple_GET_ITEM(ann_tuple, i),
PyTuple_GET_ITEM(ann_tuple, i + 1));
if (err < 0) {
return NULL;
}

  • We allocate ann_dict
  • If PyDict_SetItem fails, we return NULL
  • We don't deallocate the dict

I will send a PR.

Linked PRs

@sobolevn sobolevn added type-bug An unexpected behavior, bug, or error interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Jul 24, 2024
@sobolevn sobolevn self-assigned this Jul 24, 2024
sobolevn added a commit to sobolevn/cpython that referenced this issue Jul 24, 2024
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jul 24, 2024
nohlson pushed a commit to nohlson/cpython that referenced this issue Jul 24, 2024
nohlson pushed a commit to nohlson/cpython that referenced this issue Jul 24, 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