]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Plug more leaks
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 26 Jun 2019 12:04:32 +0000 (13:04 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 26 Jun 2019 12:04:32 +0000 (13:04 +0100)
src/libmime/lang_detection.c
src/libserver/rspamd_symcache.c
src/libserver/task.c
src/libutil/map.c

index bb00fb31de8ad2fa0cd519fe738daded22ad8469..3f2a501341deca5dee710e4aeada76e1c0707fb7 100644 (file)
@@ -494,7 +494,8 @@ rspamd_language_detector_read_file (struct rspamd_config *cfg,
                                        rspamd_ftok_t *tok;
                                        gchar *dst;
 
-                                       tok = g_malloc (sizeof (*tok) + wlen + 1);
+                                       tok = rspamd_mempool_alloc (cfg->cfg_pool,
+                                                       sizeof (*tok) + wlen + 1);
                                        dst = ((gchar *)tok) + sizeof (*tok);
                                        rspamd_strlcpy (dst, saved, wlen + 1);
                                        tok->begin = dst;
@@ -737,8 +738,6 @@ static void
 rspamd_language_detector_dtor (struct rspamd_lang_detector *d)
 {
        if (d) {
-               rspamd_ftok_t *tok;
-
                for (guint i = 0; i < RSPAMD_LANGUAGE_MAX; i ++) {
                        kh_destroy (rspamd_trigram_hash, d->trigramms[i]);
                        rspamd_multipattern_destroy (d->stop_words[i].mp);
@@ -749,10 +748,6 @@ rspamd_language_detector_dtor (struct rspamd_lang_detector *d)
                        g_ptr_array_free (d->languages, TRUE);
                }
 
-               kh_foreach_key (d->stop_words_norm, tok, {
-                       g_free (tok); /* String is embedded and freed automatically */
-               });
-
                kh_destroy (rspamd_stopwords_hash, d->stop_words_norm);
        }
 }
index 943987cc62c3ad9cb3db99ca09138d77b907fda6..59423368eae84b2d23f65c41cd03d134d44466cc 100644 (file)
@@ -1149,6 +1149,7 @@ rspamd_symcache_destroy (struct rspamd_symcache *cache)
                g_ptr_array_free (cache->postfilters, TRUE);
                g_ptr_array_free (cache->idempotent, TRUE);
                g_ptr_array_free (cache->composites, TRUE);
+               g_ptr_array_free (cache->virtual, TRUE);
                REF_RELEASE (cache->items_by_order);
 
                if (cache->peak_cb != -1) {
index 04be617448f58d401a54b3d00784cb6caadcd033..4017b009468b5cde3adcc67a1f8734075d9cab8c 100644 (file)
@@ -271,7 +271,7 @@ rspamd_task_free (struct rspamd_task *task)
                                g_array_free (tp->normalized_hashes, TRUE);
                        }
                        if (tp->languages) {
-                               g_ptr_array_unref (tp->languages);
+                               g_ptr_array_free (tp->languages, TRUE);
                        }
                }
 
index 9f43fa253f659b727bcf50fe2e9ddd95f2f2d720..458d298ddc083540937d404b1f9010c73b2feeb4 100644 (file)
@@ -1178,8 +1178,10 @@ rspamd_map_periodic_callback (struct ev_loop *loop, ev_timer *w, int revents)
 {
        struct map_periodic_cbdata *cbd = (struct map_periodic_cbdata *)w->data;
 
+       MAP_RETAIN (cbd, "periodic");
        ev_timer_stop (loop, w);
        rspamd_map_process_periodic (cbd);
+       MAP_RELEASE (cbd, "periodic");
 }
 
 static void