diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-07-16 14:13:22 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-07-16 14:13:22 -0300 |
commit | 298f383ffcc30d0799fbca0293175f647fe6bccf (patch) | |
tree | b96f7572dd4e185007d20436db45c505976c3122 /lfunc.c | |
parent | 758c1ef445ab27d89bace746111add04083a8e20 (diff) | |
download | lua-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.c | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -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 */ |