aboutsummaryrefslogtreecommitdiff
path: root/lapi.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-11-26 14:16:17 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-11-26 14:16:17 -0200
commit7696c6474fe51ed59fee324e78c1233af74febdd (patch)
treed5e674cf214a14df38ca39b02177f5cea75b581c /lapi.c
parent7e63d3da0240325db4011f5d2f2e8abfb5d60288 (diff)
downloadlua-7696c6474fe51ed59fee324e78c1233af74febdd.tar.gz
lua-7696c6474fe51ed59fee324e78c1233af74febdd.tar.bz2
lua-7696c6474fe51ed59fee324e78c1233af74febdd.zip
Auxiliary buffer cannot close box with 'lua_remove'
To remove a to-be-closed variable from the stack in the C API a function must use 'lua_settop' or 'lua_pop'. Previous implementation of 'luaL_pushresult' was not closing the box. (This commit also added tests to check that box is being closed "as soon as possible".)
Diffstat (limited to 'lapi.c')
-rw-r--r--lapi.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lapi.c b/lapi.c
index da866a66..147ed0ff 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1213,8 +1213,8 @@ LUA_API void lua_toclose (lua_State *L, int idx) {
1213 lua_lock(L); 1213 lua_lock(L);
1214 o = index2stack(L, idx); 1214 o = index2stack(L, idx);
1215 nresults = L->ci->nresults; 1215 nresults = L->ci->nresults;
1216 api_check(L, L->openupval == NULL || uplevel(L->openupval) < o, 1216 api_check(L, L->openupval == NULL || uplevel(L->openupval) <= o,
1217 "there is an already marked index below"); 1217 "marked index below or equal new one");
1218 luaF_newtbcupval(L, o); /* create new to-be-closed upvalue */ 1218 luaF_newtbcupval(L, o); /* create new to-be-closed upvalue */
1219 if (!hastocloseCfunc(nresults)) /* function not marked yet? */ 1219 if (!hastocloseCfunc(nresults)) /* function not marked yet? */
1220 L->ci->nresults = codeNresults(nresults); /* mark it */ 1220 L->ci->nresults = codeNresults(nresults); /* mark it */