Skip to content

Commit 6710156

Browse files
authored
pythongh-139988: fix a leak when failing to create a Union type (python#139990)
1 parent a18843d commit 6710156

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix a memory leak when failing to create a :class:`~typing.Union` type.
2+
Patch by Bénédikt Tran.

Objects/unionobject.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,11 +474,13 @@ _Py_union_from_tuple(PyObject *args)
474474
}
475475
if (PyTuple_CheckExact(args)) {
476476
if (!unionbuilder_add_tuple(&ub, args)) {
477+
unionbuilder_finalize(&ub);
477478
return NULL;
478479
}
479480
}
480481
else {
481482
if (!unionbuilder_add_single(&ub, args)) {
483+
unionbuilder_finalize(&ub);
482484
return NULL;
483485
}
484486
}

0 commit comments

Comments
 (0)