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
This commit is contained in:
Jeff Davis 2026-01-29 10:37:09 -08:00
parent 99b0786e07
commit a4515c9b41

View file

@ -1435,6 +1435,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 :-( */
@ -2231,6 +2234,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;
}