[3.14] gh-139988: fix a leak when failing to create a Union type (GH-139990) (#139993)

gh-139988: fix a leak when failing to create a Union type (GH-139990)
(cherry picked from commit 6710156bd2)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
This commit is contained in:
Miss Islington (bot) 2025-10-12 13:16:43 +02:00 committed by GitHub
parent ae91b4bcd0
commit 3b9694a8e6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 0 deletions

View file

@ -474,11 +474,13 @@ _Py_union_from_tuple(PyObject *args)
}
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;
}
}