diff --git a/contrib/pg_trgm/trgm_op.c b/contrib/pg_trgm/trgm_op.c index 22bcc3c3361..408b6f57704 100644 --- a/contrib/pg_trgm/trgm_op.c +++ b/contrib/pg_trgm/trgm_op.c @@ -919,7 +919,7 @@ calc_word_similarity(char *str1, int slen1, char *str2, int slen2, found[j] = true; } } - if (found[j]) + if (len > 0 && found[j]) ulen1++; /* Run iterative procedure to find maximum similarity with word */