]> source.dussan.org Git - rspamd.git/commitdiff
Allow adding maps without description from lua.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 23 Aug 2014 17:35:20 +0000 (10:35 -0700)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 23 Aug 2014 17:35:20 +0000 (10:35 -0700)
src/lua/lua_config.c

index 5dfbe90d6c8e3507cbdde6fd06235dd1970dcec8..777ed33fdd0df0057f1481dcde31f4761599c86b 100644 (file)
@@ -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));