summaryrefslogtreecommitdiff
path: root/contrib/fuzzystrmatch/sql/fuzzystrmatch.sql
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2023-05-16 10:53:42 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2023-05-16 10:53:42 -0400
commiteaf99e4c4ae4084b8261e5e1f9c2c93004a98638 (patch)
tree4432e741afe2b22cc98fa1b9ada1e4572b432173 /contrib/fuzzystrmatch/sql/fuzzystrmatch.sql
parentf06156da18f67bc2c904c0a76b70dafcb14ca7c2 (diff)
downloadpostgresql-REL_15_STABLE.tar.gz
Ensure Soundex difference() function handles empty input sanely.REL_15_STABLE
fuzzystrmatch's difference() function assumes that _soundex() always initializes its output buffer fully. This was not so for the case of a string containing no alphabetic characters, resulting in unstable output and Valgrind complaints. Fix by using memset() to fill the whole buffer in the early-exit case. Also make some cosmetic improvements (I didn't care for the random switches between "instr[0]" and "*instr" notation). Report and diagnosis by Alexander Lakhin (bug #17935). Back-patch to all supported branches. Discussion: https://postgr.es/m/17935-b99316aa79c18513@postgresql.org
Diffstat (limited to 'contrib/fuzzystrmatch/sql/fuzzystrmatch.sql')
-rw-r--r--contrib/fuzzystrmatch/sql/fuzzystrmatch.sql1
1 files changed, 1 insertions, 0 deletions
diff --git a/contrib/fuzzystrmatch/sql/fuzzystrmatch.sql b/contrib/fuzzystrmatch/sql/fuzzystrmatch.sql
index f05dc28ffb..1d0e2197fb 100644
--- a/contrib/fuzzystrmatch/sql/fuzzystrmatch.sql
+++ b/contrib/fuzzystrmatch/sql/fuzzystrmatch.sql
@@ -6,6 +6,7 @@ SELECT soundex('hello world!');
SELECT soundex('Anne'), soundex('Ann'), difference('Anne', 'Ann');
SELECT soundex('Anne'), soundex('Andrew'), difference('Anne', 'Andrew');
SELECT soundex('Anne'), soundex('Margaret'), difference('Anne', 'Margaret');
+SELECT soundex(''), difference('', '');
SELECT levenshtein('GUMBO', 'GAMBOL');