From 894f381033c6ed0b6fa285603571d6f791754bad Mon Sep 17 00:00:00 2001 From: dormando Date: Sun, 7 May 2023 23:26:12 -0700 Subject: proxy: fix config_routes numeric table copy If the table returned from config_pools had numeric keys it would fail to copy them into config_routes properly. Without patch: Failed to execute mcp_config_routes: t/config.lua:9: attempt to concatenate a nil value (field 'integer index') function mcp_config_routes() return { [1] = "val" } end --- proxy_config.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/proxy_config.c b/proxy_config.c index 98af5c2..b3ec6c1 100644 --- a/proxy_config.c +++ b/proxy_config.c @@ -347,10 +347,10 @@ static void _copy_config_table(lua_State *from, lua_State *to, LIBEVENT_THREAD * lua_pushlstring(to, lua_tostring(from, -2), lua_rawlen(from, -2)); break; case LUA_TNUMBER: - if (lua_isinteger(from, -1)) { - lua_pushinteger(to, lua_tointeger(from, -1)); + if (lua_isinteger(from, -2)) { + lua_pushinteger(to, lua_tointeger(from, -2)); } else { - lua_pushnumber(to, lua_tonumber(from, -1)); + lua_pushnumber(to, lua_tonumber(from, -2)); } break; default: -- cgit v1.2.1