diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-07-02 16:49:27 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-07-02 16:51:10 +0100 |
commit | 70eeb25c715ae22800aa96385221f9d8054be375 (patch) | |
tree | 716d2a6017dac60f5c2b215742df9fda343959a0 /src | |
parent | af66b629a1ddbc14b678ebbd2ba5925998d1b67d (diff) | |
download | rspamd-70eeb25c715ae22800aa96385221f9d8054be375.tar.gz rspamd-70eeb25c715ae22800aa96385221f9d8054be375.zip |
[Minor] Fix some issues
Diffstat (limited to 'src')
-rw-r--r-- | src/lua/lua_config.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c index 5a4d3efdc..6abddc4ff 100644 --- a/src/lua/lua_config.c +++ b/src/lua/lua_config.c @@ -3352,15 +3352,21 @@ lua_metric_symbol_inserter (gpointer k, gpointer v, gpointer ud) lua_settable (L, -3); } - lua_pushstring (L, "groups"); - lua_createtable (L, s->groups->len, 0); + if (s->groups && s->groups->len > 0) { + lua_pushstring (L, "groups"); + lua_createtable (L, s->groups->len, 0); - PTR_ARRAY_FOREACH (s->groups, i, gr) { - lua_pushstring (L, gr->name); - lua_rawseti (L, -2, i + 1); /* Groups[i + 1] = group_name */ - } + PTR_ARRAY_FOREACH (s->groups, i, gr) { + lua_pushstring (L, gr->name); + lua_rawseti (L, -2, i + 1); /* Groups[i + 1] = group_name */ + } - lua_settable (L, -3); /* Groups -> groups_table */ + lua_settable (L, -3); /* Groups -> groups_table */ + } + else { + lua_createtable (L, 0, 0); + lua_setfield (L, -2, "groups"); + } lua_settable (L, -3); /* Symname -> table */ } @@ -3380,7 +3386,7 @@ lua_config_get_symbols (lua_State *L) lua_createtable (L, 0, g_hash_table_size (cfg->symbols)); g_hash_table_foreach (cfg->symbols, lua_metric_symbol_inserter, - &cfg); + &cbd); } else { return luaL_error (L, "invalid arguments"); |