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

gh-126240: handle NULL returned by _Py_asdl_expr_seq_new #126241

Merged
merged 1 commit into from
Oct 31, 2024
Merged
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
9 changes: 9 additions & 0 deletions Parser/action_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -1128,6 +1128,9 @@ expr_ty _PyPegen_collect_call_seqs(Parser *p, asdl_expr_seq *a, asdl_seq *b,
}

asdl_expr_seq *args = _Py_asdl_expr_seq_new(total_len, arena);
if (args == NULL) {
return NULL;
}

Py_ssize_t i = 0;
for (i = 0; i < args_len; i++) {
Expand Down Expand Up @@ -1298,6 +1301,9 @@ unpack_top_level_joined_strs(Parser *p, asdl_expr_seq *raw_expressions)
}

asdl_expr_seq *expressions = _Py_asdl_expr_seq_new(req_size, p->arena);
if (expressions == NULL) {
return NULL;
}

Py_ssize_t raw_index, req_index = 0;
for (raw_index = 0; raw_index < raw_size; raw_index++) {
Expand Down Expand Up @@ -1490,6 +1496,9 @@ expr_ty _PyPegen_formatted_value(Parser *p, expr_ty expression, Token *debug, Re
}

asdl_expr_seq *values = _Py_asdl_expr_seq_new(2, arena);
if (values == NULL) {
return NULL;
}
asdl_seq_SET(values, 0, debug_text);
asdl_seq_SET(values, 1, formatted_value);
return _PyAST_JoinedStr(values, lineno, col_offset, debug_end_line, debug_end_offset, p->arena);
Expand Down
Loading