From 110591d5c1fde5358975a0d4b5710a5f5b09a6f5 Mon Sep 17 00:00:00 2001 From: Zoltan Celedes Date: Sat, 3 Jan 2026 15:51:46 +1100 Subject: [PATCH] Fix key/value pairs in Lua Previously, the keys and values were swapped in d.custom.items() --- src/rpc/lua.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/rpc/lua.cc b/src/rpc/lua.cc index d0ba44b3..5311de92 100644 --- a/src/rpc/lua.cc +++ b/src/rpc/lua.cc @@ -266,8 +266,10 @@ object_to_lua(lua_State* l_state, torrent::Object const& object) { lua_createtable(l_state, 0, static_cast(object_map.size())); int table_idx = lua_gettop(l_state); for (const auto& itr : object_map) { - object_to_lua(l_state, itr.second); + // lua_rawset requires the value to be on top of the stack, with the + // key below it. lua_pushlstring(l_state, itr.first.c_str(), itr.first.size()); + object_to_lua(l_state, itr.second); lua_rawset(l_state, table_idx); } break;