]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Fix runtime issues
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 6 Oct 2016 20:56:13 +0000 (21:56 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 6 Oct 2016 20:56:13 +0000 (21:56 +0100)
src/libserver/cfg_rcl.c
src/libstat/stat_config.c

index b770e14ad03084cc84df489492d97d37e99213bf..5cfd73ee30b203a8d17f6d34f0e30a769f7173a1 100644 (file)
@@ -880,6 +880,12 @@ rspamd_rcl_set_lua_globals (struct rspamd_config *cfg, lua_State *L,
                lua_setglobal (L, "rspamd_classifiers");
        }
 
+       lua_getglobal (L, "classifiers");
+       if (lua_isnil (L, -1)) {
+               lua_newtable (L);
+               lua_setglobal (L, "classifiers");
+       }
+
        lua_getglobal (L, "rspamd_version");
        if (lua_isnil (L, -1)) {
                lua_pushcfunction (L, rspamd_rcl_lua_version);
index 59159da63aeae749ef0290d00190987e18a83e98..f153be73745c758f6b96d12664633eded19071e1 100644 (file)
@@ -115,7 +115,7 @@ rspamd_stat_init (struct rspamd_config *cfg, struct event_base *ev_base)
        if (lua_type (L, -1) == LUA_TTABLE) {
                lua_pushnil (L);
 
-               while (lua_next (L, -1) != 0) {
+               while (lua_next (L, -2) != 0) {
                        lua_classifiers_cnt ++;
                        lua_pop (L, 1);
                }
@@ -138,7 +138,7 @@ rspamd_stat_init (struct rspamd_config *cfg, struct event_base *ev_base)
        if (lua_type (L, -1) == LUA_TTABLE) {
                lua_pushnil (L);
 
-               while (lua_next (L, -1) != 0) {
+               while (lua_next (L, -2) != 0) {
                        lua_pushvalue (L, -2);
                        memcpy (&stat_ctx->classifiers_subrs[i], &lua_classifier,
                                                        sizeof (struct rspamd_stat_classifier));