]> source.dussan.org Git - rspamd.git/commitdiff
Fix a huge memory leak in hyperscan
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 15 Jan 2016 13:41:38 +0000 (13:41 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 15 Jan 2016 13:41:38 +0000 (13:41 +0000)
src/libserver/re_cache.c

index e9a18cfdd26cdb72ed1e75d6757adce55db99103..82bd55dacb3d1b7a2fa58be5933011f34aafe674 100644 (file)
@@ -1440,7 +1440,22 @@ rspamd_re_cache_load_hyperscan (struct rspamd_re_cache *cache,
                        }
 
                        munmap (map, st.st_size);
+
+                       if (re_class->hs_scratch != NULL) {
+                               hs_free_scratch (re_class->hs_scratch);
+                       }
+
+                       if (re_class->hs_db != NULL) {
+                               hs_free_database (re_class->hs_db);
+                       }
+
+                       if (re_class->hs_ids) {
+                               g_free (re_class->hs_ids);
+                       }
+
+                       re_class->hs_ids = NULL;
                        re_class->hs_scratch = NULL;
+                       re_class->hs_db = NULL;
                        g_assert (hs_alloc_scratch (re_class->hs_db,
                                        &re_class->hs_scratch) == HS_SUCCESS);