From 5b4b47c6c4d81d0ca082617293d7284396998e0d Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Sat, 5 Mar 2011 19:29:41 +0300 Subject: [PATCH] Fix memory access. --- src/plugins/regexp.c | 2 +- src/worker.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/regexp.c b/src/plugins/regexp.c index 0ab4451e1..24d238d81 100644 --- a/src/plugins/regexp.c +++ b/src/plugins/regexp.c @@ -908,7 +908,7 @@ process_regexp (struct rspamd_regexp *re, struct worker_task *task, const gchar debug_task ("found header \"%s\" with value \"%s\"", re->header, (const gchar *)cur->data); rh = cur->data; /* Try to match regexp */ - if (g_regex_match_full (re->regexp, rh->value, -1, 0, 0, NULL, &err) == TRUE) { + if (rh->value && g_regex_match_full (re->regexp, rh->value, -1, 0, 0, NULL, &err) == TRUE) { if (G_UNLIKELY (re->is_test)) { msg_info ("process test regexp %s for header %s with value '%s' returned TRUE", re->regexp_text, re->header, (const gchar *)cur->data); } diff --git a/src/worker.c b/src/worker.c index 738002209..8f1177326 100644 --- a/src/worker.c +++ b/src/worker.c @@ -465,12 +465,12 @@ compare_email_func (gconstpointer a, gconstpointer b) const struct uri *u1 = a, *u2 = b; gint r; - if (u1->hostlen != u2->hostlen) { + if (u1->hostlen != u2->hostlen || u1->hostlen == 0) { return u1->hostlen - u2->hostlen; } else { if ((r = g_ascii_strncasecmp (u1->host, u2->host, u1->hostlen)) == 0){ - if (u1->userlen != u2->userlen) { + if (u1->userlen != u2->userlen || u1->userlen == 0) { return u1->userlen - u2->userlen; } else { @@ -491,7 +491,7 @@ compare_url_func (gconstpointer a, gconstpointer b) const struct uri *u1 = a, *u2 = b; int r; - if (u1->hostlen != u2->hostlen) { + if (u1->hostlen != u2->hostlen || u1->hostlen == 0) { return u1->hostlen - u2->hostlen; } else { -- 2.39.5