1
0
mirror of https://github.com/postgres/postgres.git synced 2025-04-29 13:56:47 +03:00

Avoid potential UCollator leak for older ICU versions.

ICU versions 53 and earlier rely on icu_set_collation_attributes() to
process the attributes in the locale string. Avoid leaking the
already-opened UCollator object if an error is encountered.

Discussion: https://postgr.es/m/04182066-7655-344a-b8b7-040b1b2490fb%40enterprisedb.com
Reviewed-by: Peter Eisentraut
This commit is contained in:
Jeff Davis 2023-03-24 08:47:51 -07:00
parent 9a24289915
commit a03b3b6b4a

View File

@ -2810,11 +2810,14 @@ icu_set_collation_attributes(UCollator *collator, const char *loc)
* message across ICU versions. * message across ICU versions.
*/ */
if (U_FAILURE(status)) if (U_FAILURE(status))
{
ucol_close(collator);
ereport(ERROR, ereport(ERROR,
(errmsg("could not open collator for locale \"%s\": %s", (errmsg("could not open collator for locale \"%s\": %s",
loc, u_errorName(status)))); loc, u_errorName(status))));
} }
} }
}
pfree(lower_str); pfree(lower_str);
} }