summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBénédikt Tran <10796600+picnixz@users.noreply.github.com>2024-10-31 14:24:07 (GMT)
committerGitHub <noreply@github.com>2024-10-31 14:24:07 (GMT)
commit94639f6b7182c2e1a82f2f907b03b5b15202acfa (patch)
tree7a099a06087abbd0ce0f11bb8d47f50e28ce3ea1
parent01415213d72504eafc159721a8f55d57b374fd9c (diff)
downloadcpython-94639f6b7182c2e1a82f2f907b03b5b15202acfa.zip
cpython-94639f6b7182c2e1a82f2f907b03b5b15202acfa.tar.gz
cpython-94639f6b7182c2e1a82f2f907b03b5b15202acfa.tar.bz2
gh-126240: handle `NULL` returned by `_Py_asdl_expr_seq_new` (#126241)
check return value of `_Py_asdl_expr_seq_new`
-rw-r--r--Parser/action_helpers.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/Parser/action_helpers.c b/Parser/action_helpers.c
index cb21777..5ac1dd7 100644
--- a/Parser/action_helpers.c
+++ b/Parser/action_helpers.c
@@ -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++) {
@@ -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++) {
@@ -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);