aboutsummaryrefslogtreecommitdiff
path: root/lapi.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2025-03-13 15:30:52 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2025-03-13 15:30:52 -0300
commit22974326ca0d4f893849ce722cc1d65b3e228f42 (patch)
tree1b4cb2cad1c55edce63e9fe6e468b1833950397d /lapi.c
parentc931d86e98da320c71da70c16d44aa28e9755520 (diff)
downloadlua-22974326ca0d4f893849ce722cc1d65b3e228f42.tar.gz
lua-22974326ca0d4f893849ce722cc1d65b3e228f42.tar.bz2
lua-22974326ca0d4f893849ce722cc1d65b3e228f42.zip
Use after free in 'luaV_finishset'
If a metatable is a weak table, its __newindex field could be collected by an emergency collection while being used in 'luaV_finishset'. (This bug has similarities with bug 5.3.2-1, fixed in commit a272fa66.)
Diffstat (limited to 'lapi.c')
-rw-r--r--lapi.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/lapi.c b/lapi.c
index a5e94507..eab12cac 100644
--- a/lapi.c
+++ b/lapi.c
@@ -681,6 +681,11 @@ static int auxgetstr (lua_State *L, const TValue *t, const char *k) {
681} 681}
682 682
683 683
684/*
685** The following function assumes that the registry cannot be a weak
686** table, so that en mergency collection while using the global table
687** cannot collect it.
688*/
684static void getGlobalTable (lua_State *L, TValue *gt) { 689static void getGlobalTable (lua_State *L, TValue *gt) {
685 Table *registry = hvalue(&G(L)->l_registry); 690 Table *registry = hvalue(&G(L)->l_registry);
686 lu_byte tag = luaH_getint(registry, LUA_RIDX_GLOBALS, gt); 691 lu_byte tag = luaH_getint(registry, LUA_RIDX_GLOBALS, gt);