]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Fix use-after-free
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 18 Oct 2019 10:34:49 +0000 (11:34 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 18 Oct 2019 10:35:08 +0000 (11:35 +0100)
src/libutil/map_helpers.c

index 9f3dacad8152a0122fd06aaea91e180cafa5b34e..a9bd8d70eaf978869b745b39c46707c786c1849c 100644 (file)
@@ -770,15 +770,6 @@ rspamd_map_helper_destroy_regexp (struct rspamd_regexp_map_helper *re_map)
                return;
        }
 
-       for (i = 0; i < re_map->regexps->len; i ++) {
-               re = g_ptr_array_index (re_map->regexps, i);
-               rspamd_regexp_unref (re);
-       }
-
-       g_ptr_array_free (re_map->regexps, TRUE);
-       g_ptr_array_free (re_map->values, TRUE);
-       kh_destroy (rspamd_map_hash, re_map->htb);
-
 #ifdef WITH_HYPERSCAN
        if (re_map->hs_scratch) {
                hs_free_scratch (re_map->hs_scratch);
@@ -801,6 +792,15 @@ rspamd_map_helper_destroy_regexp (struct rspamd_regexp_map_helper *re_map)
        }
 #endif
 
+       for (i = 0; i < re_map->regexps->len; i ++) {
+               re = g_ptr_array_index (re_map->regexps, i);
+               rspamd_regexp_unref (re);
+       }
+
+       g_ptr_array_free (re_map->regexps, TRUE);
+       g_ptr_array_free (re_map->values, TRUE);
+       kh_destroy (rspamd_map_hash, re_map->htb);
+
        rspamd_mempool_t *pool = re_map->pool;
        memset (re_map, 0, sizeof (*re_map));
        rspamd_mempool_delete (pool);