From 19435d299a1fae9ad9a6bbe6609e41ddfd7f6cbe Mon Sep 17 00:00:00 2001 From: Kirill Podoprigora Date: Wed, 12 Jun 2024 10:37:14 +0300 Subject: gh-120385: Fix reference leak in symtable (#120386) Decref 'new_ste' if symtable_visit_annotations() fails. --- Python/symtable.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Python/symtable.c b/Python/symtable.c index 287bc2b..627184d 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -2027,8 +2027,10 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) } if (!symtable_visit_annotations(st, s, s->v.AsyncFunctionDef.args, - s->v.AsyncFunctionDef.returns, new_ste)) + s->v.AsyncFunctionDef.returns, new_ste)) { + Py_DECREF(new_ste); VISIT_QUIT(st, 0); + } if (!symtable_enter_existing_block(st, new_ste)) { Py_DECREF(new_ste); VISIT_QUIT(st, 0); -- cgit v0.12