1
1
/*
2
- ** $Id: lvm.c,v 2.63.1.3 2007/12/28 15:32:23 roberto Exp $
2
+ ** $Id: lvm.c,v 2.63.1.5 2011/08/17 20:43:11 roberto Exp $
3
3
** Lua virtual machine
4
4
** See Copyright Notice in lua.h
5
5
*/
@@ -133,6 +133,7 @@ void luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId val) {
133
133
134
134
void luaV_settable (lua_State * L , const TValue * t , TValue * key , StkId val ) {
135
135
int loop ;
136
+ TValue temp ;
136
137
for (loop = 0 ; loop < MAXTAGLOOP ; loop ++ ) {
137
138
const TValue * tm ;
138
139
if (ttistable (t )) { /* `t' is a table? */
@@ -141,6 +142,7 @@ void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) {
141
142
if (!ttisnil (oldval ) || /* result is no nil? */
142
143
(tm = fasttm (L , h -> metatable , TM_NEWINDEX )) == NULL ) { /* or no TM? */
143
144
setobj2t (L , oldval , val );
145
+ h -> flags = 0 ;
144
146
luaC_barriert (L , h , val );
145
147
return ;
146
148
}
@@ -152,7 +154,9 @@ void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) {
152
154
callTM (L , tm , t , key , val );
153
155
return ;
154
156
}
155
- t = tm ; /* else repeat with `tm' */
157
+ /* else repeat with `tm' */
158
+ setobj (L , & temp , tm ); /* avoid pointing inside table (may rehash) */
159
+ t = & temp ;
156
160
}
157
161
luaG_runerror (L , "loop in settable" );
158
162
}
0 commit comments