aboutsummaryrefslogtreecommitdiffstats
path: root/src/filter.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2011-03-02 21:44:02 +0300
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2011-03-02 21:44:02 +0300
commit0f2f88a6157250fecb9ce5d8d28b02b99739a2d2 (patch)
tree154d2efebe84ad274de17fef59756a4a46ff09fa /src/filter.c
parent2d18269774d7541f3690973d568187c7e45448e5 (diff)
downloadrspamd-0f2f88a6157250fecb9ce5d8d28b02b99739a2d2.tar.gz
rspamd-0f2f88a6157250fecb9ce5d8d28b02b99739a2d2.zip
Try to fix memory issues.
Diffstat (limited to 'src/filter.c')
-rw-r--r--src/filter.c43
1 files changed, 25 insertions, 18 deletions
diff --git a/src/filter.c b/src/filter.c
index d41c85ff0..68a43d1f9 100644
--- a/src/filter.c
+++ b/src/filter.c
@@ -84,35 +84,37 @@ insert_metric_result (struct worker_task *task, struct metric *metric, const gch
/* Add metric score */
- if ((s = g_hash_table_lookup (metric_res->symbols, symbol)) != NULL) {
- if (!single) {
- if (s->options && opts && opts != s->options) {
- /* Append new options */
- s->options = g_list_concat (s->options, g_list_copy(opts));
- /*
- * Note that there is no need to add new destructor of GList as elements of appended
- * GList are used directly, so just free initial GList
- */
- }
- else if (opts) {
- s->options = opts;
- memory_pool_add_destructor (task->task_pool, (pool_destruct_func) g_list_free, s->options);
- }
-
- s->score += w;
- metric_res->score += w;
+ if (!single && (s = g_hash_table_lookup (metric_res->symbols, symbol)) != NULL) {
+ if (s->options && opts && opts != s->options) {
+ /* Append new options */
+ s->options = g_list_concat (s->options, g_list_copy(opts));
+ /*
+ * Note that there is no need to add new destructor of GList as elements of appended
+ * GList are used directly, so just free initial GList
+ */
}
+ else if (opts) {
+ s->options = g_list_copy (opts);
+ memory_pool_add_destructor (task->task_pool, (pool_destruct_func) g_list_free, s->options);
+ }
+
+ s->score += w;
+ metric_res->score += w;
}
else {
s = memory_pool_alloc (task->task_pool, sizeof (struct symbol));
s->score = w;
- s->options = opts;
+
s->name = symbol;
metric_res->score += w;
if (opts) {
+ s->options = g_list_copy (opts);
memory_pool_add_destructor (task->task_pool, (pool_destruct_func) g_list_free, s->options);
}
+ else {
+ s->options = NULL;
+ }
g_hash_table_insert (metric_res->symbols, (gpointer) symbol, s);
}
@@ -165,6 +167,11 @@ insert_result_common (struct worker_task *task, const gchar *symbol, double flag
cur = g_list_next (cur);
}
}
+
+ if (opts != NULL) {
+ /* XXX: it is not wise to destroy them here */
+ g_list_free (opts);
+ }
}
/* Insert result that may be increased on next insertions */