]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Fix memory leaks in pg_locale_icu.c.
authorJeff Davis <jdavis@postgresql.org>
Thu, 29 Jan 2026 18:37:09 +0000 (10:37 -0800)
committerJeff Davis <jdavis@postgresql.org>
Thu, 26 Feb 2026 20:15:31 +0000 (12:15 -0800)
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

src/backend/utils/adt/pg_locale.c

index b9e1ade862b9f69b162df00e588e721e19b79c53..bee165cd6a17181deaea9c6192de92da40d5a0d4 100644 (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;
 }