Skip to content

Commit 76d270e

Browse files
Erlend Egeberg Aaslandpablogsal
andauthored
[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 c0e11a3) Co-authored-by: Erlend Egeberg Aasland <[email protected]> * Update Parser/pegen/pegen.c Co-authored-by: Pablo Galindo <[email protected]>
1 parent 299ae9c commit 76d270e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Parser/pegen/pegen.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,10 @@ _PyPegen_fill_token(Parser *p)
639639
if (t->bytes == NULL) {
640640
return -1;
641641
}
642-
PyArena_AddPyObject(p->arena, t->bytes);
642+
if (PyArena_AddPyObject(p->arena, t->bytes) < 0) {
643+
Py_DECREF(t->bytes);
644+
return -1;
645+
}
643646

644647
int lineno = type == STRING ? p->tok->first_lineno : p->tok->lineno;
645648
const char *line_start = type == STRING ? p->tok->multi_line_start : p->tok->line_start;

0 commit comments

Comments
 (0)