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/[email protected]
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/1d369c9e90f311ec98b07a259cac48c404c773d5
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(-)