aboutsummaryrefslogtreecommitdiff
path: root/lvm.c
diff options
context:
space:
mode:
Diffstat (limited to 'lvm.c')
-rw-r--r--lvm.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/lvm.c b/lvm.c
index f0e73f9b..af048d81 100644
--- a/lvm.c
+++ b/lvm.c
@@ -325,6 +325,11 @@ lu_byte luaV_finishget (lua_State *L, const TValue *t, TValue *key,
325 325
326/* 326/*
327** Finish a table assignment 't[key] = val'. 327** Finish a table assignment 't[key] = val'.
328** About anchoring the table before the call to 'luaH_finishset':
329** This call may trigger an emergency collection. When loop>0,
330** the table being acessed is a field in some metatable. If this
331** metatable is weak and the table is not anchored, this collection
332** could collect that table while it is being updated.
328*/ 333*/
329void luaV_finishset (lua_State *L, const TValue *t, TValue *key, 334void luaV_finishset (lua_State *L, const TValue *t, TValue *key,
330 TValue *val, int hres) { 335 TValue *val, int hres) {
@@ -335,7 +340,10 @@ void luaV_finishset (lua_State *L, const TValue *t, TValue *key,
335 Table *h = hvalue(t); /* save 't' table */ 340 Table *h = hvalue(t); /* save 't' table */
336 tm = fasttm(L, h->metatable, TM_NEWINDEX); /* get metamethod */ 341 tm = fasttm(L, h->metatable, TM_NEWINDEX); /* get metamethod */
337 if (tm == NULL) { /* no metamethod? */ 342 if (tm == NULL) { /* no metamethod? */
343 sethvalue2s(L, L->top.p, h); /* anchor 't' */
344 L->top.p++; /* assume EXTRA_STACK */
338 luaH_finishset(L, h, key, val, hres); /* set new value */ 345 luaH_finishset(L, h, key, val, hres); /* set new value */
346 L->top.p--;
339 invalidateTMcache(h); 347 invalidateTMcache(h);
340 luaC_barrierback(L, obj2gco(h), val); 348 luaC_barrierback(L, obj2gco(h), val);
341 return; 349 return;