From 907d172c1114a2d61e85e1ca7aba50ef1fc4ffe3 Mon Sep 17 00:00:00 2001 From: Roberto I Date: Wed, 20 Aug 2025 15:00:53 -0300 Subject: Added lock/unlock to API function 'lua_rawlen' The call to 'luaH_getn' can change the "field" 'lenhint' of a table. --- lapi.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lapi.c') diff --git a/lapi.c b/lapi.c index 0c88751a..55e371dc 100644 --- a/lapi.c +++ b/lapi.c @@ -440,7 +440,13 @@ LUA_API lua_Unsigned lua_rawlen (lua_State *L, int idx) { case LUA_VSHRSTR: return cast(lua_Unsigned, tsvalue(o)->shrlen); case LUA_VLNGSTR: return cast(lua_Unsigned, tsvalue(o)->u.lnglen); case LUA_VUSERDATA: return cast(lua_Unsigned, uvalue(o)->len); - case LUA_VTABLE: return luaH_getn(L, hvalue(o)); + case LUA_VTABLE: { + lua_Unsigned res; + lua_lock(L); + res = luaH_getn(L, hvalue(o)); + lua_unlock(L); + return res; + } default: return 0; } } -- cgit v1.2.3-55-g6feb