]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Oops, fix table iteration
authorVsevolod Stakhov <vsevolod@rspamd.com>
Sat, 14 May 2022 13:38:25 +0000 (14:38 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Sat, 14 May 2022 13:38:25 +0000 (14:38 +0100)
src/lua/lua_config.c

index b2333eab1e0a9a6c6213cbac058daee48390634f..aee5e25ae7f758d0208e2ea7f11aa7857e30a34c 100644 (file)
@@ -2082,8 +2082,8 @@ lua_config_register_symbol (lua_State * L)
                        lua_gettable (L, 2);
 
                        if (lua_type (L, -1) == LUA_TTABLE) {
-
-                               for (lua_pushnil (L); lua_next (L, 2); lua_pop (L, 1)) {
+                               int tbl_idx = lua_gettop(L);
+                               for (lua_pushnil(L); lua_next(L, tbl_idx); lua_pop (L, 1)) {
                                        rspamd_symcache_add_symbol_augmentation(cfg->cache, ret,
                                                        lua_tostring(L, -1));
                                }
@@ -2778,7 +2778,8 @@ lua_config_newindex (lua_State *L)
 
                                if (lua_type (L, -1) == LUA_TTABLE) {
 
-                                       for (lua_pushnil(L); lua_next(L, 2); lua_pop (L, 1)) {
+                                       int tbl_idx = lua_gettop(L);
+                                       for (lua_pushnil(L); lua_next(L, tbl_idx); lua_pop (L, 1)) {
                                                rspamd_symcache_add_symbol_augmentation(cfg->cache, id,
                                                                lua_tostring(L, -1));
                                        }