From c0e11a3ceb9427e09db4224f394c7789bf6deec5 Mon Sep 17 00:00:00 2001 From: Erlend Egeberg Aasland Date: Fri, 9 Apr 2021 01:05:44 +0200 Subject: Fix possible refleak involving _PyArena_AddPyObject (GH-25289) --- Parser/pegen.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Parser/pegen.c b/Parser/pegen.c index 82dcd3b..7b5a5e9 100644 --- a/Parser/pegen.c +++ b/Parser/pegen.c @@ -690,7 +690,10 @@ _PyPegen_fill_token(Parser *p) if (t->bytes == NULL) { return -1; } - _PyArena_AddPyObject(p->arena, t->bytes); + if (_PyArena_AddPyObject(p->arena, t->bytes) < 0) { + Py_DECREF(t->bytes); + return -1; + } int lineno = type == STRING ? p->tok->first_lineno : p->tok->lineno; const char *line_start = type == STRING ? p->tok->multi_line_start : p->tok->line_start; -- cgit v0.12