pgsql: Ensure Soundex difference() function handles empty input sanely. - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Ensure Soundex difference() function handles empty input sanely.
Date
Msg-id E1pyw3t-0007oZ-Ht@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Ensure Soundex difference() function handles empty input sanely.

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

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/0966291a4ade47f7c14313ab7868d1de4e4f6688

Modified Files
--------------
contrib/fuzzystrmatch/expected/fuzzystrmatch.out |  6 ++++++
contrib/fuzzystrmatch/fuzzystrmatch.c            | 15 ++++++++-------
contrib/fuzzystrmatch/sql/fuzzystrmatch.sql      |  1 +
3 files changed, 15 insertions(+), 7 deletions(-)


pgsql-committers by date:

Previous
From: Alvaro Herrera
Date:
Subject: pgsql: libpq: Error message improvement
Next
From: Damir Belyalov
Date:
Subject: Re: pgsql: Refactor background psql TAP functions