From 80042384b477519ee2b137a841b5a825675bedf5 Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Thu, 31 Oct 2024 15:57:11 +0100 Subject: [PATCH] [3.13] gh-126240: handle `NULL` returned by `_Py_asdl_expr_seq_new` (GH-126241) (#126243) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit gh-126240: handle `NULL` returned by `_Py_asdl_expr_seq_new` (GH-126241) check return value of `_Py_asdl_expr_seq_new` (cherry picked from commit 94639f6b7182c2e1a82f2f907b03b5b15202acfa) Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> --- Parser/action_helpers.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Parser/action_helpers.c b/Parser/action_helpers.c index 34f744516c1..8dfc919da71 100644 --- a/Parser/action_helpers.c +++ b/Parser/action_helpers.c @@ -1120,6 +1120,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++) { @@ -1290,6 +1293,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++) { @@ -1482,6 +1488,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);