diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2009-04-28 14:13:32 +0400 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2009-04-28 14:13:32 +0400 |
commit | 99caa0aca331669149c7b77b4a5d851a3e0a2b49 (patch) | |
tree | 9aafe05c61df69c6f9241f1ee10906a1a8617276 /src | |
parent | d3b5b3d8b0aa135db14375ed141f586f4ae1ea07 (diff) | |
download | rspamd-99caa0aca331669149c7b77b4a5d851a3e0a2b49.tar.gz rspamd-99caa0aca331669149c7b77b4a5d851a3e0a2b49.zip |
* Avoid division by zero while comparing fuzzy hashes
Diffstat (limited to 'src')
-rw-r--r-- | src/fuzzy.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/fuzzy.c b/src/fuzzy.c index a53ed929d..49bb9da27 100644 --- a/src/fuzzy.c +++ b/src/fuzzy.c @@ -273,6 +273,11 @@ fuzzy_compare_hashes (fuzzy_hash_t *h1, fuzzy_hash_t *h2) l1 = strlen (h1->hash_pipe); l2 = strlen (h2->hash_pipe); + + if (l1 == 0 || l2 == 0) { + return 0; + } + res = lev_distance (h1->hash_pipe, l1, h2->hash_pipe, l2); res = (res * 100) / (l1 + l2); |