Fix possible refleak involving _PyArena_AddPyObject (GH-25289)

This commit is contained in:
Erlend Egeberg Aasland 2021-04-09 01:05:44 +02:00 committed by GitHub
parent 1e051a21b7
commit c0e11a3ceb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View 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;