aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver/cfg_utils.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-06-14 11:47:36 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-06-14 15:15:19 +0100
commit7406e60b74327df055f3bacfc478bd5cb68fd6c9 (patch)
tree9589f52da4b7e19f2eb0997674503763107619af /src/libserver/cfg_utils.c
parent700949bd941aeec41060163e36509061791c502f (diff)
downloadrspamd-7406e60b74327df055f3bacfc478bd5cb68fd6c9.tar.gz
rspamd-7406e60b74327df055f3bacfc478bd5cb68fd6c9.zip
[Fix] Cleanup maps data on shutdown
Diffstat (limited to 'src/libserver/cfg_utils.c')
-rw-r--r--src/libserver/cfg_utils.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c
index e58232a00..ef5d89ff6 100644
--- a/src/libserver/cfg_utils.c
+++ b/src/libserver/cfg_utils.c
@@ -56,6 +56,7 @@ static gchar * rspamd_ucl_read_cb (gchar * chunk,
struct map_cb_data *data,
gboolean final);
static void rspamd_ucl_fin_cb (struct map_cb_data *data);
+static void rspamd_ucl_dtor_cb (struct map_cb_data *data);
guint rspamd_config_log_id = (guint)-1;
RSPAMD_CONSTRUCTOR(rspamd_config_log_init)
@@ -1083,7 +1084,8 @@ rspamd_include_map_handler (const guchar *data, gsize len,
"ucl include",
rspamd_ucl_read_cb,
rspamd_ucl_fin_cb,
- (void **)pcbdata);
+ rspamd_ucl_dtor_cb,
+ (void **)pcbdata) != NULL;
}
/*
@@ -1364,6 +1366,19 @@ rspamd_ucl_fin_cb (struct map_cb_data *data)
}
}
+static void
+rspamd_ucl_dtor_cb (struct map_cb_data *data)
+{
+ struct rspamd_ucl_map_cbdata *cbdata = data->cur_data;
+
+ if (cbdata != NULL) {
+ if (cbdata->buf != NULL) {
+ g_string_free (cbdata->buf, TRUE);
+ }
+ g_free (cbdata);
+ }
+}
+
gboolean
rspamd_check_module (struct rspamd_config *cfg, module_t *mod)
{
@@ -1888,7 +1903,10 @@ rspamd_config_radix_from_ucl (struct rspamd_config *cfg,
if (rspamd_map_is_map (str)) {
if (rspamd_map_add_from_ucl (cfg, cur_elt,
- description, rspamd_radix_read, rspamd_radix_fin,
+ description,
+ rspamd_radix_read,
+ rspamd_radix_fin,
+ rspamd_radix_dtor,
(void **)target) == NULL) {
g_set_error (err, g_quark_from_static_string ("rspamd-config"),
EINVAL, "bad map definition %s for %s", str,
@@ -1908,7 +1926,10 @@ rspamd_config_radix_from_ucl (struct rspamd_config *cfg,
case UCL_OBJECT:
/* Should be a map description */
if (rspamd_map_add_from_ucl (cfg, cur_elt,
- description, rspamd_radix_read, rspamd_radix_fin,
+ description,
+ rspamd_radix_read,
+ rspamd_radix_fin,
+ rspamd_radix_dtor,
(void **)target) == NULL) {
g_set_error (err, g_quark_from_static_string ("rspamd-config"),
EINVAL, "bad map object for %s", ucl_object_key (obj));