From: Erlend Egeberg Aasland Date: Fri, 9 Apr 2021 17:46:32 +0000 (+0200) Subject: [3.9] bpo-43779: Fix possible refleak involving _PyArena_AddPyObject (GH-25289).... X-Git-Tag: v3.9.5~88 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=76d270ec2b776cc5331935cc58c2d63622f1c0e9;p=thirdparty%2FPython%2Fcpython.git [3.9] bpo-43779: Fix possible refleak involving _PyArena_AddPyObject (GH-25289). (GH-25294) * [3.9] Fix possible refleak involving _PyArena_AddPyObject (GH-25289). (cherry picked from commit c0e11a3ceb9427e09db4224f394c7789bf6deec5) Co-authored-by: Erlend Egeberg Aasland * Update Parser/pegen/pegen.c Co-authored-by: Pablo Galindo --- diff --git a/Parser/pegen/pegen.c b/Parser/pegen/pegen.c index 0a26275b23e0..111009af63e2 100644 --- a/Parser/pegen/pegen.c +++ b/Parser/pegen/pegen.c @@ -639,7 +639,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;