From: Vsevolod Stakhov Date: Tue, 10 May 2016 15:27:11 +0000 (+0100) Subject: [CritFix] Fix levenshtein distance calculations X-Git-Tag: 1.2.7~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5e3d57dae1aa1cd57cb3b34aa9e2e0e2a6f0269e;p=thirdparty%2Frspamd.git [CritFix] Fix levenshtein distance calculations --- diff --git a/src/libmime/message.c b/src/libmime/message.c index 18ef81fb22..2a7498fb90 100644 --- a/src/libmime/message.c +++ b/src/libmime/message.c @@ -1093,7 +1093,7 @@ rspamd_words_levenshtein_distance (struct rspamd_task *task, { guint s1len, s2len, x, y, lastdiag, olddiag; guint *column, ret; - guint64 *h1, *h2; + guint64 h1, h2; gint eq; static const guint max_words = 8192; @@ -1117,9 +1117,9 @@ rspamd_words_levenshtein_distance (struct rspamd_task *task, for (y = 1, lastdiag = x - 1; y <= s1len; y++) { olddiag = column[y]; - h1 = &g_array_index (w1, guint64, y - 1); - h2 = &g_array_index (w2, guint64, x - 1); - eq = h1 == h2; + h1 = g_array_index (w1, guint64, y - 1); + h2 = g_array_index (w2, guint64, x - 1); + eq = (h1 == h2) ? 1 : 0; /* * Cost of replacement is twice higher than cost of add/delete * to calculate percentage properly