diff options
| author | Roberto I <roberto@inf.puc-rio.br> | 2025-08-20 15:00:53 -0300 |
|---|---|---|
| committer | Roberto I <roberto@inf.puc-rio.br> | 2025-08-20 15:00:53 -0300 |
| commit | 907d172c1114a2d61e85e1ca7aba50ef1fc4ffe3 (patch) | |
| tree | 41dd562701cf065b16660ed521ba97b73d0640ff /lapi.c | |
| parent | 88aa4049ad3e638571bfffcf5fd8b6a8e07c6aaf (diff) | |
| download | lua-907d172c1114a2d61e85e1ca7aba50ef1fc4ffe3.tar.gz lua-907d172c1114a2d61e85e1ca7aba50ef1fc4ffe3.tar.bz2 lua-907d172c1114a2d61e85e1ca7aba50ef1fc4ffe3.zip | |
Added lock/unlock to API function 'lua_rawlen'
The call to 'luaH_getn' can change the "field" 'lenhint' of a table.
Diffstat (limited to 'lapi.c')
| -rw-r--r-- | lapi.c | 8 |
1 files changed, 7 insertions, 1 deletions
| @@ -440,7 +440,13 @@ LUA_API lua_Unsigned lua_rawlen (lua_State *L, int idx) { | |||
| 440 | case LUA_VSHRSTR: return cast(lua_Unsigned, tsvalue(o)->shrlen); | 440 | case LUA_VSHRSTR: return cast(lua_Unsigned, tsvalue(o)->shrlen); |
| 441 | case LUA_VLNGSTR: return cast(lua_Unsigned, tsvalue(o)->u.lnglen); | 441 | case LUA_VLNGSTR: return cast(lua_Unsigned, tsvalue(o)->u.lnglen); |
| 442 | case LUA_VUSERDATA: return cast(lua_Unsigned, uvalue(o)->len); | 442 | case LUA_VUSERDATA: return cast(lua_Unsigned, uvalue(o)->len); |
| 443 | case LUA_VTABLE: return luaH_getn(L, hvalue(o)); | 443 | case LUA_VTABLE: { |
| 444 | lua_Unsigned res; | ||
| 445 | lua_lock(L); | ||
| 446 | res = luaH_getn(L, hvalue(o)); | ||
| 447 | lua_unlock(L); | ||
| 448 | return res; | ||
| 449 | } | ||
| 444 | default: return 0; | 450 | default: return 0; |
| 445 | } | 451 | } |
| 446 | } | 452 | } |
