summaryrefslogtreecommitdiffstats
path: root/Parser/pegen.c
diff options
context:
space:
mode:
authorErlend Egeberg Aasland <erlend.aasland@innova.no>2021-04-08 23:05:44 (GMT)
committerGitHub <noreply@github.com>2021-04-08 23:05:44 (GMT)
commitc0e11a3ceb9427e09db4224f394c7789bf6deec5 (patch)
treecbb3723e713e4c3ac00185fadf2459d8d4e974db /Parser/pegen.c
parent1e051a21b7106a93c30b74aad7e1f40d6c0c477b (diff)
downloadcpython-c0e11a3ceb9427e09db4224f394c7789bf6deec5.zip
cpython-c0e11a3ceb9427e09db4224f394c7789bf6deec5.tar.gz
cpython-c0e11a3ceb9427e09db4224f394c7789bf6deec5.tar.bz2
Fix possible refleak involving _PyArena_AddPyObject (GH-25289)
Diffstat (limited to 'Parser/pegen.c')
-rw-r--r--Parser/pegen.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/Parser/pegen.c b/Parser/pegen.c
index 82dcd3b..7b5a5e9 100644
--- a/Parser/pegen.c
+++ b/Parser/pegen.c
@@ -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;