Skip to content

Commit 02ab63e

Browse files
committed
fixup! gh-103656: Transfer f-string buffers to parser to avoid use-after-free
1 parent af320d3 commit 02ab63e

File tree

2 files changed

+96
-107
lines changed

2 files changed

+96
-107
lines changed

Parser/action_helpers.c

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,27 +1223,6 @@ _PyPegen_nonparen_genexp_in_call(Parser *p, expr_ty args, asdl_comprehension_seq
12231223

12241224
// Fstring stuff
12251225

1226-
static expr_ty
1227-
decode_fstring_buffer(Parser *p, int lineno, int col_offset, int end_lineno,
1228-
int end_col_offset)
1229-
{
1230-
tokenizer_mode *tok_mode = &(p->tok->tok_mode_stack[p->tok->tok_mode_stack_index]);
1231-
assert(tok_mode->last_expr_buffer != NULL);
1232-
assert(tok_mode->last_expr_size >= 0 && tok_mode->last_expr_end >= 0);
1233-
1234-
PyObject *res = PyUnicode_DecodeUTF8(
1235-
tok_mode->last_expr_buffer,
1236-
tok_mode->last_expr_size - tok_mode->last_expr_end,
1237-
NULL
1238-
);
1239-
if (!res || _PyArena_AddPyObject(p->arena, res) < 0) {
1240-
Py_XDECREF(res);
1241-
return NULL;
1242-
}
1243-
1244-
return _PyAST_Constant(res, NULL, lineno, col_offset, end_lineno, end_col_offset, p->arena);
1245-
}
1246-
12471226
static expr_ty
12481227
_PyPegen_decode_fstring_part(Parser* p, int is_raw, expr_ty constant) {
12491228
assert(PyUnicode_CheckExact(constant->v.Constant.value));

0 commit comments

Comments
 (0)