gh-139988: fix a leak when failing to create a Union type (#139990)

This commit is contained in:
Bénédikt Tran 2025-10-12 12:51:44 +02:00 committed by GitHub
parent a18843dbfb
commit 6710156bd2
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;
}
}