Skip to content

gh-135302: Fix NULL pointer dereference in has_kwonlydefaults function #135303

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
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Python/symtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -1780,6 +1780,9 @@ symtable_record_directive(struct symtable *st, identifier name, _Py_SourceLocati
static int
has_kwonlydefaults(asdl_arg_seq *kwonlyargs, asdl_expr_seq *kw_defaults)
{
if (!kw_defaults) {
return 0;
}
Comment on lines +1783 to +1785
Copy link
Member

@picnixz picnixz Jun 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the loop won't be executed if we pass a NULL because s->v.AsyncFunctionDef.args->kwonlyargs would have a sequence length of 0 (for the existing calls). So I think we should add an assertion instead or leave the code as is.

for (int i = 0; i < asdl_seq_LEN(kwonlyargs); i++) {
expr_ty default_ = asdl_seq_GET(kw_defaults, i);
if (default_) {
Expand Down
Loading