From 99caa0aca331669149c7b77b4a5d851a3e0a2b49 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 28 Apr 2009 14:13:32 +0400 Subject: [PATCH] * Avoid division by zero while comparing fuzzy hashes --- src/fuzzy.c | 5 +++++ 1 file changed, 5 insertions(+) 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); -- 2.39.5