diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-08-23 10:35:20 -0700 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-08-23 10:35:20 -0700 |
commit | 336972d7e512db2c78d6facdd35e3a27e7f319fe (patch) | |
tree | ea7bfc1b8b29d36a844bcba03374045604cc13cd | |
parent | f17e998db0fadcb2a1d9fcc61dd7f0aa9e3a3964 (diff) | |
download | rspamd-336972d7e512db2c78d6facdd35e3a27e7f319fe.tar.gz rspamd-336972d7e512db2c78d6facdd35e3a27e7f319fe.zip |
Allow adding maps without description from lua.
-rw-r--r-- | src/lua/lua_config.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c index 5dfbe90d6..777ed33fd 100644 --- a/src/lua/lua_config.c +++ b/src/lua/lua_config.c @@ -1021,16 +1021,25 @@ lua_config_add_map (lua_State *L) struct rspamd_config *cfg = lua_check_config (L); const gchar *map_line, *description; struct lua_map_callback_data *cbdata, **pcbdata; + int cbidx; if (cfg) { map_line = luaL_checkstring (L, 2); - description = lua_tostring (L, 3); - if (lua_type (L, 4) == LUA_TFUNCTION) { + if (lua_gettop (L) == 4) { + description = lua_tostring (L, 3); + cbidx = 4; + } + else { + description = NULL; + cbidx = 3; + } + + if (lua_type (L, cbidx) == LUA_TFUNCTION) { cbdata = g_slice_alloc (sizeof (*cbdata)); cbdata->L = L; cbdata->data = NULL; - lua_pushvalue (L, 4); + lua_pushvalue (L, cbidx); /* Get a reference */ cbdata->ref = luaL_ref (L, LUA_REGISTRYINDEX); pcbdata = rspamd_mempool_alloc (cfg->cfg_pool, sizeof (cbdata)); |