summaryrefslogtreecommitdiff
path: root/ldo.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-02-17 16:22:00 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-02-17 16:22:00 -0200
commit104d249ffbf76828caa5e204979f5ddad45f2bcb (patch)
tree40e6c53872ba42d4887ccd0eb391accc66edbcee /ldo.c
parentc7a8cba74512a16aa01a99f2cdf395b358ada2fc (diff)
downloadlua-github-104d249ffbf76828caa5e204979f5ddad45f2bcb.tar.gz
in return hook, 'top' must be corrected only if smaller than 'ci->top'.
(It may be larger when returning multiple values, and then it must be larger to preserve that stack slice.)
Diffstat (limited to 'ldo.c')
-rw-r--r--ldo.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/ldo.c b/ldo.c
index 19d6aefd..f797df29 100644
--- a/ldo.c
+++ b/ldo.c
@@ -1,5 +1,5 @@
/*
-** $Id: ldo.c,v 2.193 2018/02/09 15:16:06 roberto Exp roberto $
+** $Id: ldo.c,v 2.194 2018/02/15 15:34:29 roberto Exp roberto $
** Stack and Call structure of Lua
** See Copyright Notice in lua.h
*/
@@ -316,7 +316,8 @@ static void rethook (lua_State *L, CallInfo *ci) {
Proto *p = clLvalue(s2v(ci->func))->p;
if (p->is_vararg)
delta = ci->u.l.nextraargs + p->numparams + 1;
- L->top = ci->top; /* prepare top */
+ if (L->top < ci->top)
+ L->top = ci->top; /* correct top */
}
if (L->hookmask & LUA_MASKRET) { /* is return hook on? */
ci->func += delta; /* if vararg, back to virtual 'func' */