aboutsummaryrefslogtreecommitdiff
path: root/lfunc.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-07-16 14:13:22 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-07-16 14:13:22 -0300
commit298f383ffcc30d0799fbca0293175f647fe6bccf (patch)
treeb96f7572dd4e185007d20436db45c505976c3122 /lfunc.c
parent758c1ef445ab27d89bace746111add04083a8e20 (diff)
downloadlua-298f383ffcc30d0799fbca0293175f647fe6bccf.tar.gz
lua-298f383ffcc30d0799fbca0293175f647fe6bccf.tar.bz2
lua-298f383ffcc30d0799fbca0293175f647fe6bccf.zip
Avoid setting the stack top below upvalues to be closed
When leaving a scope, the new stack top should be set only after closing any upvalue, to avoid manipulating values in an "invalid" part of the stack.
Diffstat (limited to 'lfunc.c')
-rw-r--r--lfunc.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/lfunc.c b/lfunc.c
index 55114992..68d0632a 100644
--- a/lfunc.c
+++ b/lfunc.c
@@ -202,6 +202,7 @@ int luaF_close (lua_State *L, StkId level, int status) {
202 while ((uv = L->openupval) != NULL && uplevel(uv) >= level) { 202 while ((uv = L->openupval) != NULL && uplevel(uv) >= level) {
203 StkId upl = uplevel(uv); 203 StkId upl = uplevel(uv);
204 TValue *slot = &uv->u.value; /* new position for value */ 204 TValue *slot = &uv->u.value; /* new position for value */
205 lua_assert(upl < L->top);
205 luaF_unlinkupval(uv); 206 luaF_unlinkupval(uv);
206 setobj(L, slot, uv->v); /* move value to upvalue slot */ 207 setobj(L, slot, uv->v); /* move value to upvalue slot */
207 uv->v = slot; /* now current value lives here */ 208 uv->v = slot; /* now current value lives here */