aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2017-12-28 12:17:09 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2017-12-28 12:17:09 -0200
commit8691612f01ae4b32d861464032521d969766c1c5 (patch)
treec9c79856a333421360fd434ab933b40b7cbd10d9
parentf99f3c42fffe0b9672e6380c83de19db65b4f9d4 (diff)
downloadlua-8691612f01ae4b32d861464032521d969766c1c5.tar.gz
lua-8691612f01ae4b32d861464032521d969766c1c5.tar.bz2
lua-8691612f01ae4b32d861464032521d969766c1c5.zip
when calling a hook, cannot decrease 'ci->top' (to preserve stack
size if the stack is reallocated)
-rw-r--r--ldo.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/ldo.c b/ldo.c
index 77c408ba..6a28e8ee 100644
--- a/ldo.c
+++ b/ldo.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldo.c,v 2.182 2017/12/19 16:40:17 roberto Exp roberto $ 2** $Id: ldo.c,v 2.183 2017/12/20 14:58:05 roberto Exp roberto $
3** Stack and Call structure of Lua 3** Stack and Call structure of Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -278,8 +278,8 @@ void luaD_hook (lua_State *L, int event, int line) {
278 ar.currentline = line; 278 ar.currentline = line;
279 ar.i_ci = ci; 279 ar.i_ci = ci;
280 luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ 280 luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */
281 ci->top = L->top + LUA_MINSTACK; 281 if (L->top + LUA_MINSTACK > ci->top)
282 lua_assert(ci->top <= L->stack_last); 282 ci->top = L->top + LUA_MINSTACK;
283 L->allowhook = 0; /* cannot call hooks inside a hook */ 283 L->allowhook = 0; /* cannot call hooks inside a hook */
284 ci->callstatus |= CIST_HOOKED; 284 ci->callstatus |= CIST_HOOKED;
285 lua_unlock(L); 285 lua_unlock(L);
@@ -294,7 +294,7 @@ void luaD_hook (lua_State *L, int event, int line) {
294} 294}
295 295
296 296
297static void callhook (lua_State *L, CallInfo *ci, int istail) { 297static void hookcall (lua_State *L, CallInfo *ci, int istail) {
298 int hook; 298 int hook;
299 ci->u.l.trap = 1; 299 ci->u.l.trap = 1;
300 if (!(L->hookmask & LUA_MASKCALL)) 300 if (!(L->hookmask & LUA_MASKCALL))
@@ -429,7 +429,7 @@ void luaD_pretailcall (lua_State *L, CallInfo *ci, StkId func, int n) {
429 ci->u.l.savedpc = p->code; /* starting point */ 429 ci->u.l.savedpc = p->code; /* starting point */
430 ci->callstatus |= CIST_TAIL; 430 ci->callstatus |= CIST_TAIL;
431 if (L->hookmask) 431 if (L->hookmask)
432 callhook(L, ci, 1); 432 hookcall(L, ci, 1);
433} 433}
434 434
435 435
@@ -484,7 +484,7 @@ void luaD_call (lua_State *L, StkId func, int nresults) {
484 ci->u.l.savedpc = p->code; /* starting point */ 484 ci->u.l.savedpc = p->code; /* starting point */
485 ci->callstatus = 0; 485 ci->callstatus = 0;
486 if (L->hookmask) 486 if (L->hookmask)
487 callhook(L, ci, 0); 487 hookcall(L, ci, 0);
488 luaV_execute(L, ci); /* run the function */ 488 luaV_execute(L, ci); /* run the function */
489 break; 489 break;
490 } 490 }