Browse Source

avoid calling "tail return" hooks if the hook itself turns off the event

Roberto Ierusalimschy 17 years ago
parent
commit
e7c989baf1
1 changed files with 2 additions and 2 deletions
  1. 2 2
      ldo.c

+ 2 - 2
ldo.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: ldo.c,v 2.44 2006/10/10 17:40:17 roberto Exp roberto $
+** $Id: ldo.c,v 2.45 2007/03/27 14:11:38 roberto Exp roberto $
 ** Stack and Call structure of Lua
 ** Stack and Call structure of Lua
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -332,7 +332,7 @@ static StkId callrethooks (lua_State *L, StkId firstResult) {
   ptrdiff_t fr = savestack(L, firstResult);  /* next call may change stack */
   ptrdiff_t fr = savestack(L, firstResult);  /* next call may change stack */
   luaD_callhook(L, LUA_HOOKRET, -1);
   luaD_callhook(L, LUA_HOOKRET, -1);
   if (f_isLua(L->ci)) {  /* Lua function? */
   if (f_isLua(L->ci)) {  /* Lua function? */
-    while (L->ci->tailcalls--)  /* call hook for possible tail calls */
+    while ((L->hookmask & LUA_MASKRET) && L->ci->tailcalls--) /* tail calls */
       luaD_callhook(L, LUA_HOOKTAILRET, -1);
       luaD_callhook(L, LUA_HOOKTAILRET, -1);
   }
   }
   return restorestack(L, fr);
   return restorestack(L, fr);