commit f41ac57: [Fix] Fix use-after-free
Vsevolod Stakhov
vsevolod at highsecure.ru
Fri Oct 18 10:42:06 UTC 2019
Author: Vsevolod Stakhov
Date: 2019-10-18 11:34:49 +0100
URL: https://github.com/rspamd/rspamd/commit/f41ac57b3a61a1abfe562a930734a45f36ba5604 (HEAD -> master)
[Fix] Fix use-after-free
---
src/libutil/map_helpers.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/src/libutil/map_helpers.c b/src/libutil/map_helpers.c
index 9f3dacad8..a9bd8d70e 100644
--- a/src/libutil/map_helpers.c
+++ b/src/libutil/map_helpers.c
@@ -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);
More information about the Commits
mailing list