diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-03-08 14:40:00 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-03-08 14:40:00 +0000 |
commit | fa31a3408b2cf293b1c4f7b2f707121df10d4dfb (patch) | |
tree | f9a619630d5a0c25bc03d03799c755ddc1d3ca51 | |
parent | 6f79b02003ac372ac635f7dc9b19e3bdd0573545 (diff) | |
download | rspamd-fa31a3408b2cf293b1c4f7b2f707121df10d4dfb.tar.gz rspamd-fa31a3408b2cf293b1c4f7b2f707121df10d4dfb.zip |
[Fix] Fix calling of lua map callbacks
-rw-r--r-- | src/lua/lua_map.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/lua/lua_map.c b/src/lua/lua_map.c index 232076e1d..eba020a85 100644 --- a/src/lua/lua_map.c +++ b/src/lua/lua_map.c @@ -347,7 +347,7 @@ lua_map_fin (rspamd_mempool_t * pool, struct map_cb_data *data) *pmap = cbdata->lua_map; rspamd_lua_setclass (cbdata->L, "rspamd{map}", -1); - if (lua_pcall (cbdata->L, -1, 0, 0) != 0) { + if (lua_pcall (cbdata->L, 2, 0, 0) != 0) { msg_info_pool ("call to %s failed: %s", "local function", lua_tostring (cbdata->L, -1)); lua_pop (cbdata->L, 1); @@ -361,7 +361,7 @@ lua_config_add_map (lua_State *L) struct rspamd_config *cfg = lua_check_config (L, 1); const gchar *map_line, *description; struct lua_map_callback_data *cbdata; - struct rspamd_lua_map *map; + struct rspamd_lua_map *map, **pmap; struct rspamd_map *m; int cbidx; @@ -403,11 +403,13 @@ lua_config_add_map (lua_State *L) lua_map_read, lua_map_fin, (void **)&map->data.cbdata)) == NULL) { msg_warn_config ("invalid map %s", map_line); - lua_pushboolean (L, false); + lua_pushnil (L); } else { map->map = m; - lua_pushboolean (L, true); + pmap = lua_newuserdata (L, sizeof (void *)); + *pmap = map; + rspamd_lua_setclass (L, "rspamd{map}", -1); } } else { |