From: Vsevolod Stakhov Date: Tue, 28 Apr 2009 10:13:32 +0000 (+0400) Subject: * Avoid division by zero while comparing fuzzy hashes X-Git-Tag: 0.2.7~165 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=99caa0aca331669149c7b77b4a5d851a3e0a2b49;p=rspamd.git * Avoid division by zero while comparing fuzzy hashes --- 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);