]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.9] bpo-43779: Fix possible refleak involving _PyArena_AddPyObject (GH-25289)....
authorErlend Egeberg Aasland <erlend.aasland@innova.no>
Fri, 9 Apr 2021 17:46:32 +0000 (19:46 +0200)
committerGitHub <noreply@github.com>
Fri, 9 Apr 2021 17:46:32 +0000 (18:46 +0100)
* [3.9] Fix possible refleak involving _PyArena_AddPyObject (GH-25289).
(cherry picked from commit c0e11a3ceb9427e09db4224f394c7789bf6deec5)

Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
* Update Parser/pegen/pegen.c

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
Parser/pegen/pegen.c

index 0a26275b23e0d06b63a21146949ca69030bdb98b..111009af63e22a2dee4778022f341637f150c9de 100644 (file)
@@ -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;