Added lock/unlock to API function 'lua_rawlen'
The call to 'luaH_getn' can change the "field" 'lenhint' of a table.
This commit is contained in:
1 parent
88aa4049ad
commit
907d172c11
1 file changed
+7
-1
@@ -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_VSHRSTR: return cast(lua_Unsigned, tsvalue(o)->shrlen);
|
||||||
case LUA_VLNGSTR: return cast(lua_Unsigned, tsvalue(o)->u.lnglen);
|
case LUA_VLNGSTR: return cast(lua_Unsigned, tsvalue(o)->u.lnglen);
|
||||||
case LUA_VUSERDATA: return cast(lua_Unsigned, uvalue(o)->len);
|
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;
|
default: return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user