Skip to content

Commit

Permalink
[Fix] Fix crash due to constructors init order
Browse files Browse the repository at this point in the history
Issue: #3079
  • Loading branch information
vstakhov committed Oct 12, 2019
1 parent 08ffbdd commit 42a4b08
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/libutil/mem_pool.c
Expand Up @@ -111,7 +111,7 @@ pool_chain_free (struct _pool_chain *chain)
chain->slice_size - occupied : 0);
}

/* By default allocate 8Kb chunks of memory */
/* By default allocate 4Kb chunks of memory */
#define FIXED_POOL_SIZE 4096

static inline struct rspamd_mempool_entry_point *
Expand Down Expand Up @@ -156,6 +156,7 @@ RSPAMD_DESTRUCTOR (rspamd_mempool_entries_dtor)
});

kh_destroy (mempool_entry, mempool_entries);
mempool_entries = NULL;
}

static inline struct rspamd_mempool_entry_point *
Expand Down Expand Up @@ -676,7 +677,7 @@ rspamd_mempool_delete (rspamd_mempool_t * pool)
cur = pool->pools[RSPAMD_MEMPOOL_NORMAL];
}

if (cur) {
if (cur && mempool_entries) {
pool->entry->elts[pool->entry->cur_elts].leftover =
pool_chain_free (cur);

Expand Down
10 changes: 5 additions & 5 deletions src/lua/lua_regexp.c
Expand Up @@ -889,16 +889,16 @@ lua_load_regexp (lua_State * L)
void
luaopen_regexp (lua_State * L)
{
if (!regexp_static_pool) {
regexp_static_pool = rspamd_mempool_new (rspamd_mempool_suggest_size (),
"regexp_lua_pool");
}

rspamd_lua_new_class (L, "rspamd{regexp}", regexplib_m);
lua_pop (L, 1);
rspamd_lua_add_preload (L, "rspamd_regexp", lua_load_regexp);
}

RSPAMD_CONSTRUCTOR (lua_re_static_pool_ctor) {
regexp_static_pool = rspamd_mempool_new (rspamd_mempool_suggest_size (),
"regexp_lua_pool");
}

RSPAMD_DESTRUCTOR (lua_re_static_pool_dtor) {
rspamd_mempool_delete (regexp_static_pool);
}

0 comments on commit 42a4b08

Please sign in to comment.