aboutsummaryrefslogtreecommitdiff
path: root/lvm.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-11-29 16:02:44 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-11-29 16:02:44 -0200
commit6d04537ea660fd12fc16c328366b701fabaf4919 (patch)
tree41eab6e4d87552e29731db552f7d58d679c56973 /lvm.c
parent7696c6474fe51ed59fee324e78c1233af74febdd (diff)
downloadlua-6d04537ea660fd12fc16c328366b701fabaf4919.tar.gz
lua-6d04537ea660fd12fc16c328366b701fabaf4919.tar.bz2
lua-6d04537ea660fd12fc16c328366b701fabaf4919.zip
A to-be-closed variable must have a closable value (or be nil)
It is an error for a to-be-closed variable to have a non-closable non-nil value when it is being closed. This situation does not seem to be useful and often hints to an error. (Particularly in the C API, it is easy to change a to-be-closed index by mistake.)
Diffstat (limited to 'lvm.c')
-rw-r--r--lvm.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/lvm.c b/lvm.c
index a6dcc9ff..50d967c6 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1427,7 +1427,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
1427 } 1427 }
1428 vmcase(OP_CLOSE) { 1428 vmcase(OP_CLOSE) {
1429 L->top = ra + 1; /* everything is free after this slot */ 1429 L->top = ra + 1; /* everything is free after this slot */
1430 ProtectNT(luaF_close(L, ra, LUA_OK)); 1430 Protect(luaF_close(L, ra, LUA_OK));
1431 vmbreak; 1431 vmbreak;
1432 } 1432 }
1433 vmcase(OP_TBC) { 1433 vmcase(OP_TBC) {
@@ -1717,9 +1717,8 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
1717 vmbreak; 1717 vmbreak;
1718 } 1718 }
1719 vmcase(OP_TFORPREP) { 1719 vmcase(OP_TFORPREP) {
1720 /* is 'toclose' a function or has a '__close' metamethod? */ 1720 /* is 'toclose' not nil? */
1721 if (ttisfunction(s2v(ra + 3)) || 1721 if (!ttisnil(s2v(ra + 3))) {
1722 !ttisnil(luaT_gettmbyobj(L, s2v(ra + 3), TM_CLOSE))) {
1723 /* create to-be-closed upvalue for it */ 1722 /* create to-be-closed upvalue for it */
1724 halfProtect(luaF_newtbcupval(L, ra + 3)); 1723 halfProtect(luaF_newtbcupval(L, ra + 3));
1725 } 1724 }