pgsql: Fix expanding 'bounds' in pg_trgm's calc_word_similarity() funct

From: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix expanding 'bounds' in pg_trgm's calc_word_similarity() funct
Date: 2026-02-20 09:57:51
Message-ID: E1vtNGh-000IAE-2B@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix expanding 'bounds' in pg_trgm's calc_word_similarity() function

If the 'bounds' array needs to be expanded, because the input contains
more trigrams than the initial guess, the code didn't return the
reallocated array correctly to the caller. That could lead to a crash
in the rare case that the input string becomes longer when it's
lower-cased. The only known instance of that is when an ICU locale is
used with certain single-byte encodings. This was an oversight in
commit 00896ddaf41f.

Author: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
Backpatch-through: 18

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/041e02e6a6110af871b909c55f1a1bd9d5a66cdb

Modified Files
--------------
contrib/pg_trgm/trgm_op.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Nathan Bossart 2026-02-20 18:08:20 pgsql: Speedup COPY FROM with additional function inlining.
Previous Message Richard Guo 2026-02-20 09:08:42 pgsql: Fix computation of varnullingrels when translating appendrel Var