mirror of
https://github.com/lua/lua
synced 2026-09-27 00:28:25 +03:00
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.
This commit is contained in:
parent
758c1ef445
commit
298f383ffc
3 changed files with 13 additions and 9 deletions
1
lfunc.c
1
lfunc.c
|
|
@ -202,6 +202,7 @@ int luaF_close (lua_State *L, StkId level, int status) {
|
|||
while ((uv = L->openupval) != NULL && uplevel(uv) >= level) {
|
||||
StkId upl = uplevel(uv);
|
||||
TValue *slot = &uv->u.value; /* new position for value */
|
||||
lua_assert(upl < L->top);
|
||||
luaF_unlinkupval(uv);
|
||||
setobj(L, slot, uv->v); /* move value to upvalue slot */
|
||||
uv->v = slot; /* now current value lives here */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue