gh-139988: fix a leak when failing to create a Union type (GH-139990)
(cherry picked from commit
6710156bd27dd48493d15f515506a0ead5d0328f)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
--- /dev/null
+Fix a memory leak when failing to create a :class:`~typing.Union` type.
+Patch by Bénédikt Tran.
}
if (PyTuple_CheckExact(args)) {
if (!unionbuilder_add_tuple(&ub, args)) {
+ unionbuilder_finalize(&ub);
return NULL;
}
}
else {
if (!unionbuilder_add_single(&ub, args)) {
+ unionbuilder_finalize(&ub);
return NULL;
}
}