Skip to content

Commit c0e11a3

Browse files
author
Erlend Egeberg Aasland
authored
Fix possible refleak involving _PyArena_AddPyObject (pythonGH-25289)
1 parent 1e051a2 commit c0e11a3

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Parser/pegen.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,10 @@ _PyPegen_fill_token(Parser *p)
690690
if (t->bytes == NULL) {
691691
return -1;
692692
}
693-
_PyArena_AddPyObject(p->arena, t->bytes);
693+
if (_PyArena_AddPyObject(p->arena, t->bytes) < 0) {
694+
Py_DECREF(t->bytes);
695+
return -1;
696+
}
694697

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

0 commit comments

Comments
 (0)