]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix possible refleak involving _PyArena_AddPyObject (GH-25289)
authorErlend Egeberg Aasland <erlend.aasland@innova.no>
Thu, 8 Apr 2021 23:05:44 +0000 (01:05 +0200)
committerGitHub <noreply@github.com>
Thu, 8 Apr 2021 23:05:44 +0000 (00:05 +0100)
Parser/pegen.c

index 82dcd3bb5a8586001baa53b7a673a6eb6e91c23b..7b5a5e914685714e293c1e44dbad9617a5a5e292 100644 (file)
@@ -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;