Commit 1d369c9
committed
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.org1 parent 27debd0 commit 1d369c9
File tree
3 files changed
+15
-7
lines changed- contrib/fuzzystrmatch
- expected
- sql
3 files changed
+15
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
26 | 32 | | |
27 | 33 | | |
28 | 34 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
728 | 728 | | |
729 | 729 | | |
730 | 730 | | |
731 | | - | |
732 | | - | |
733 | 731 | | |
734 | | - | |
| 732 | + | |
735 | 733 | | |
736 | 734 | | |
737 | | - | |
738 | | - | |
| 735 | + | |
| 736 | + | |
739 | 737 | | |
740 | | - | |
| 738 | + | |
741 | 739 | | |
742 | 740 | | |
743 | 741 | | |
| |||
750 | 748 | | |
751 | 749 | | |
752 | 750 | | |
753 | | - | |
| 751 | + | |
754 | 752 | | |
755 | 753 | | |
756 | 754 | | |
| |||
767 | 765 | | |
768 | 766 | | |
769 | 767 | | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
770 | 771 | | |
771 | 772 | | |
772 | 773 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
0 commit comments