diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-01-15 13:46:17 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-01-15 13:46:17 +0000 |
commit | c035e23a29d713b603e44f6bb6dcc47b47fdfcf1 (patch) | |
tree | 7017de38ff010a43c9c9ba118c19e8274b61bacb /src/libserver/re_cache.c | |
parent | c124d925f84c2ef76f57cfe9925709f2fb71eadb (diff) | |
download | rspamd-c035e23a29d713b603e44f6bb6dcc47b47fdfcf1.tar.gz rspamd-c035e23a29d713b603e44f6bb6dcc47b47fdfcf1.zip |
Do not free HS database after deserialization
Diffstat (limited to 'src/libserver/re_cache.c')
-rw-r--r-- | src/libserver/re_cache.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/libserver/re_cache.c b/src/libserver/re_cache.c index 82bd55dac..94bed145d 100644 --- a/src/libserver/re_cache.c +++ b/src/libserver/re_cache.c @@ -1429,18 +1429,7 @@ rspamd_re_cache_load_hyperscan (struct rspamd_re_cache *cache, /* Skip crc */ p += n * sizeof (*hs_ids) + sizeof (guint64); - if (hs_deserialize_database (p, end - p, &re_class->hs_db) - != HS_SUCCESS) { - msg_err_re_cache ("bad hs database in %s", path); - munmap (map, st.st_size); - g_free (hs_ids); - g_free (hs_flags); - - return FALSE; - } - - munmap (map, st.st_size); - + /* Cleanup */ if (re_class->hs_scratch != NULL) { hs_free_scratch (re_class->hs_scratch); } @@ -1456,6 +1445,19 @@ rspamd_re_cache_load_hyperscan (struct rspamd_re_cache *cache, re_class->hs_ids = NULL; re_class->hs_scratch = NULL; re_class->hs_db = NULL; + + if (hs_deserialize_database (p, end - p, &re_class->hs_db) + != HS_SUCCESS) { + msg_err_re_cache ("bad hs database in %s", path); + munmap (map, st.st_size); + g_free (hs_ids); + g_free (hs_flags); + + return FALSE; + } + + munmap (map, st.st_size); + g_assert (hs_alloc_scratch (re_class->hs_db, &re_class->hs_scratch) == HS_SUCCESS); |