aboutsummaryrefslogtreecommitdiffstats
path: root/src/libutil
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-03-27 14:25:27 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-03-27 14:25:27 +0000
commit3cc4d4ac947b8751509498b650bb024533986352 (patch)
treeec886f44398b40c76f4703203aa7266eed9904fe /src/libutil
parent7476eadbf9642b0044f27f4bdabd7ec5df107a47 (diff)
downloadrspamd-3cc4d4ac947b8751509498b650bb024533986352.tar.gz
rspamd-3cc4d4ac947b8751509498b650bb024533986352.zip
Fix AST cleanup.
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/expression.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/libutil/expression.c b/src/libutil/expression.c
index 8696c1cc6..d9f1a1260 100644
--- a/src/libutil/expression.c
+++ b/src/libutil/expression.c
@@ -864,11 +864,20 @@ rspamd_ast_process_node (struct rspamd_expression *expr, GNode *node,
return acc;
}
+static gboolean
+rspamd_ast_cleanup_traverse (GNode *n, gpointer d)
+{
+ struct rspamd_expression_elt *elt = n->data;
+
+ elt->value = 0;
+ elt->flags = 0;
+
+ return FALSE;
+}
+
gint
rspamd_process_expression (struct rspamd_expression *expr, gpointer data)
{
- struct rspamd_expression_elt *elt;
- guint i;
gint ret = 0;
g_assert (expr != NULL);
@@ -878,11 +887,8 @@ rspamd_process_expression (struct rspamd_expression *expr, gpointer data)
ret = rspamd_ast_process_node (expr, expr->ast, data);
/* Cleanup */
- for (i = 0; i < expr->expressions->len; i ++) {
- elt = &g_array_index (expr->expressions, struct rspamd_expression_elt, i);
- elt->value = 0;
- elt->flags = 0;
- }
+ g_node_traverse (expr->ast, G_IN_ORDER, G_TRAVERSE_ALL, -1,
+ rspamd_ast_cleanup_traverse, NULL);
return ret;
}