From: Vsevolod Stakhov Date: Tue, 24 Mar 2009 16:47:10 +0000 (+0300) Subject: * Fix bug in expressions parser and optimizer X-Git-Tag: 0.2.7~233 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=56033466857544978d09dc4afa53c2eb359e8ea5;p=thirdparty%2Frspamd.git * Fix bug in expressions parser and optimizer --- diff --git a/src/expressions.c b/src/expressions.c index f222ea2b40..b115eba723 100644 --- a/src/expressions.c +++ b/src/expressions.c @@ -342,16 +342,13 @@ parse_expression (memory_pool_t *pool, char *line) break; case READ_FUNCTION: - if (func == NULL) { - func = memory_pool_alloc (pool, sizeof (struct expression_function)); - } - if (*p == '/') { /* In fact it is regexp */ state = READ_REGEXP; c ++; p ++; } else if (*p == '(') { + func = memory_pool_alloc (pool, sizeof (struct expression_function)); func->name = memory_pool_alloc (pool, p - c + 1); func->args = NULL; g_strlcpy (func->name, c, (p - c + 1)); diff --git a/src/plugins/regexp.c b/src/plugins/regexp.c index 53c64d2b39..e9c4ca7bf5 100644 --- a/src/plugins/regexp.c +++ b/src/plugins/regexp.c @@ -268,13 +268,13 @@ static gboolean optimize_regexp_expression (struct expression **e, GQueue *stack, gboolean res) { struct expression *it = *e; - gboolean ret = FALSE; + gboolean ret = FALSE, is_nearest = TRUE; while (it) { /* Find first operation for this iterator */ if (it->type == EXPR_OPERATION) { /* If this operation is just ! just inverse res and check for further operators */ - if (it->content.operation == '!') { + if (it->content.operation == '!' && is_nearest) { res = !res; it = it->next; *e = it; @@ -290,6 +290,7 @@ optimize_regexp_expression (struct expression **e, GQueue *stack, gboolean res) } break; } + is_nearest = FALSE; it = it->next; }