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

ga_getitem can fail if Py_GenericAlias returns NULL #121660

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

ga_getitem can fail if Py_GenericAlias returns NULL #121660

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

Bug report

This code is problematic:

PyObject *res = Py_GenericAlias(alias->origin, newargs);
((gaobject *)res)->starred = alias->starred;
Py_DECREF(newargs);
return res;

Why? Py_GenericAlias can return NULL in different cases:

return NULL;
}
if (!setup_ga(alias, origin, args)) {
Py_DECREF(alias);
return NULL;

So, we need to check for NULL.

Linked PRs

@sobolevn sobolevn added type-bug An unexpected behavior, bug, or error interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Jul 13, 2024
@sobolevn sobolevn self-assigned this Jul 13, 2024
sobolevn added a commit to sobolevn/cpython that referenced this issue Jul 13, 2024
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jul 14, 2024
…esult (pythonGH-121661)

(cherry picked from commit bb802db)

Co-authored-by: sobolevn <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jul 14, 2024
…esult (pythonGH-121661)

(cherry picked from commit bb802db)

Co-authored-by: sobolevn <[email protected]>
sobolevn added a commit that referenced this issue Jul 14, 2024
…result (GH-121661) (#121762)

gh-121660: Fix `ga_getitem` by explicitly checking for `NULL` result (GH-121661)
(cherry picked from commit bb802db)

Co-authored-by: sobolevn <[email protected]>
sobolevn added a commit that referenced this issue Jul 14, 2024
…result (GH-121661) (#121761)

gh-121660: Fix `ga_getitem` by explicitly checking for `NULL` result (GH-121661)
(cherry picked from commit bb802db)

Co-authored-by: sobolevn <[email protected]>
estyxx pushed a commit to estyxx/cpython that referenced this issue Jul 17, 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