From: Vsevolod Stakhov Date: Sat, 23 Aug 2014 17:35:20 +0000 (-0700) Subject: Allow adding maps without description from lua. X-Git-Tag: 0.7.0~108 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=336972d7e512db2c78d6facdd35e3a27e7f319fe;p=thirdparty%2Frspamd.git Allow adding maps without description from lua. --- diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c index 5dfbe90d6c..777ed33fdd 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));