From: Jeff Davis Date: Thu, 29 Jan 2026 18:37:09 +0000 (-0800) Subject: Fix memory leaks in pg_locale_icu.c. X-Git-Tag: REL_17_10~115 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=4761f2eee6c0617f54dc7b6d95d28d9ba8f034c7;p=thirdparty%2Fpostgresql.git Fix memory leaks in pg_locale_icu.c. The backport prior to 18 requires minor modification due to code refactoring. Discussion: https://postgr.es/m/e2b7a0a88aaadded7e2d19f42d5ab03c9e182ad8.camel@j-davis.com Backpatch-through: 16 --- diff --git a/src/backend/utils/adt/pg_locale.c b/src/backend/utils/adt/pg_locale.c index c95b550b7ab..aa0114ce120 100644 --- a/src/backend/utils/adt/pg_locale.c +++ b/src/backend/utils/adt/pg_locale.c @@ -1509,6 +1509,9 @@ make_icu_collator(const char *iculocstr, ereport(ERROR, (errmsg("could not open collator for locale \"%s\" with rules \"%s\": %s", iculocstr, icurules, u_errorName(status)))); + + pfree(my_rules); + pfree(agg_rules); } /* We will leak this string if the caller errors later :-( */ @@ -2316,6 +2319,9 @@ pg_strnxfrm_prefix_icu_no_utf8(char *dest, const char *src, int32_t srclen, (errmsg("sort key generation failed: %s", u_errorName(status)))); + if (buf != sbuf) + pfree(buf); + return result_bsize; }