diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-01-17 16:54:33 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-01-17 16:54:33 +0000 |
commit | 43566f1597716ebeaac3273dbfe45e9babfff10c (patch) | |
tree | 110330737bcd8b227c3c0f43f12c4db465886502 /src/libmime/mime_expressions.c | |
parent | 8cd0a991e4fbef885dc3c68ad880b4565b1070ff (diff) | |
download | rspamd-43566f1597716ebeaac3273dbfe45e9babfff10c.tar.gz rspamd-43566f1597716ebeaac3273dbfe45e9babfff10c.zip |
[Fix] Plug memory leak in expressions parsing during reload
Diffstat (limited to 'src/libmime/mime_expressions.c')
-rw-r--r-- | src/libmime/mime_expressions.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/libmime/mime_expressions.c b/src/libmime/mime_expressions.c index 637cccad3..e8a3134c7 100644 --- a/src/libmime/mime_expressions.c +++ b/src/libmime/mime_expressions.c @@ -449,6 +449,8 @@ rspamd_mime_expr_parse_regexp_atom (rspamd_mempool_t * pool, const gchar *line, } rspamd_regexp_set_ud (result->regexp, result); + rspamd_mempool_add_destructor (pool, + (rspamd_mempool_destruct_t)rspamd_regexp_unref, result->regexp); *dend = '/'; @@ -706,9 +708,9 @@ set: return NULL; } - mime_atom = g_slice_alloc (sizeof (*mime_atom)); + mime_atom = rspamd_mempool_alloc (pool, sizeof (*mime_atom)); mime_atom->type = type; - mime_atom->str = g_malloc (p - line + 1); + mime_atom->str = rspamd_mempool_alloc (pool, p - line + 1); rspamd_strlcpy (mime_atom->str, line, p - line + 1); if (type == MIME_ATOM_REGEXP) { @@ -788,8 +790,6 @@ set: return a; err: - g_free (mime_atom->str); - g_slice_free1 (sizeof (*mime_atom), mime_atom); return NULL; } @@ -889,8 +889,6 @@ rspamd_mime_expr_destroy (rspamd_expression_atom_t *atom) } g_array_free (mime_atom->d.func->args, TRUE); } - /* XXX: regexp shouldn't be special */ - g_slice_free1 (sizeof (*mime_atom), mime_atom); } } |