diff --git a/lualib/ldblib.c b/lualib/ldblib.c index 84fe3c7..bd8df9d 100644 --- a/lualib/ldblib.c +++ b/lualib/ldblib.c @@ -1,5 +1,5 @@ /* -** $Id: ldblib.c,v 1.132.1.1 2013/04/12 18:48:47 roberto Exp $ +** $Id: ldblib.c,v 1.132.1.2 2015/02/19 17:16:55 roberto Exp $ ** Interface from Lua to its debug API ** See Copyright Notice in lua.h */ @@ -21,6 +21,11 @@ #define HOOKKEY "_HKEY" +static void checkstack (lua_State *L, lua_State *L1, int n) { + if (L != L1 && !lua_checkstack(L1, n)) + luaL_error(L, "stack overflow"); +} + static int db_getregistry (lua_State *L) { lua_pushvalue(L, LUA_REGISTRYINDEX); @@ -114,6 +119,7 @@ static int db_getinfo (lua_State *L) { int arg; lua_State *L1 = getthread(L, &arg); const char *options = luaL_optstring(L, arg+2, "flnStu"); + checkstack(L, L1, 3); if (lua_isnumber(L, arg+1)) { if (!lua_getstack(L1, (int)lua_tointeger(L, arg+1), &ar)) { lua_pushnil(L); /* level out of range */ @@ -173,6 +179,7 @@ static int db_getlocal (lua_State *L) { else { /* stack-level argument */ if (!lua_getstack(L1, luaL_checkint(L, arg+1), &ar)) /* out of range? */ return luaL_argerror(L, arg+1, "level out of range"); + checkstack(L, L1, 1); name = lua_getlocal(L1, &ar, nvar); if (name) { lua_xmove(L1, L, 1); /* push local value */ @@ -196,6 +203,7 @@ static int db_setlocal (lua_State *L) { return luaL_argerror(L, arg+1, "level out of range"); luaL_checkany(L, arg+3); lua_settop(L, arg+3); + checkstack(L, L1, 1); lua_xmove(L, L1, 1); lua_pushstring(L, lua_setlocal(L1, &ar, luaL_checkint(L, arg+2))); return 1; @@ -313,6 +321,7 @@ static int db_sethook (lua_State *L) { lua_pushvalue(L, -1); lua_setmetatable(L, -2); /* setmetatable(hooktable) = hooktable */ } + checkstack(L, L1, 1); lua_pushthread(L1); lua_xmove(L1, L, 1); lua_pushvalue(L, arg+1); lua_rawset(L, -3); /* set new hook */ @@ -331,6 +340,7 @@ static int db_gethook (lua_State *L) { lua_pushliteral(L, "external hook"); else { gethooktable(L); + checkstack(L, L1, 1); lua_pushthread(L1); lua_xmove(L1, L, 1); lua_rawget(L, -2); /* get hook */ lua_remove(L, -2); /* remove hook table */ diff --git a/lualib/ldebug.c b/lualib/ldebug.c index 20d663e..9611846 100644 --- a/lualib/ldebug.c +++ b/lualib/ldebug.c @@ -1,5 +1,5 @@ /* -** $Id: ldebug.c,v 2.90.1.3 2013/05/16 16:04:15 roberto Exp $ +** $Id: ldebug.c,v 2.90.1.4 2015/02/19 17:05:13 roberto Exp $ ** Debug Interface ** See Copyright Notice in lua.h */ @@ -47,6 +47,16 @@ static int currentline (CallInfo *ci) { } +static void swapextra (lua_State *L) { + if (L->status == LUA_YIELD) { + CallInfo *ci = L->ci; /* get function that yielded */ + StkId temp = ci->func; /* exchange its 'func' and 'extra' values */ + ci->func = restorestack(L, ci->extra); + ci->extra = savestack(L, temp); + } +} + + /* ** this function can be called asynchronous (e.g. during a signal) */ @@ -144,6 +154,7 @@ static const char *findlocal (lua_State *L, CallInfo *ci, int n, LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) { const char *name; lua_lock(L); + swapextra(L); if (ar == NULL) { /* information about non-active function? */ if (!isLfunction(L->top - 1)) /* not a Lua function? */ name = NULL; @@ -158,6 +169,7 @@ LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) { api_incr_top(L); } } + swapextra(L); lua_unlock(L); return name; } @@ -165,11 +177,14 @@ LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) { LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) { StkId pos = 0; /* to avoid warnings */ - const char *name = findlocal(L, ar->i_ci, n, &pos); + const char *name; lua_lock(L); + swapextra(L); + name = findlocal(L, ar->i_ci, n, &pos); if (name) setobjs2s(L, pos, L->top - 1); L->top--; /* pop value */ + swapextra(L); lua_unlock(L); return name; } @@ -269,6 +284,7 @@ LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) { CallInfo *ci; StkId func; lua_lock(L); + swapextra(L); if (*what == '>') { ci = NULL; func = L->top - 1; @@ -287,6 +303,7 @@ LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) { setobjs2s(L, L->top, func); api_incr_top(L); } + swapextra(L); if (strchr(what, 'L')) collectvalidlines(L, cl); lua_unlock(L); diff --git a/lualib/lgc.c b/lualib/lgc.c index 52460dc..553fd17 100644 --- a/lualib/lgc.c +++ b/lualib/lgc.c @@ -1,5 +1,5 @@ /* -** $Id: lgc.c,v 2.140.1.2 2013/04/26 18:22:05 roberto Exp $ +** $Id: lgc.c,v 2.140.1.3 2014/09/01 16:55:08 roberto Exp $ ** Garbage Collector ** See Copyright Notice in lua.h */ @@ -403,7 +403,7 @@ static int traverseephemeron (global_State *g, Table *h) { reallymarkobject(g, gcvalue(gval(n))); /* mark it now */ } } - if (prop) + if (g->gcstate != GCSatomic || prop) linktable(h, &g->ephemeron); /* have to propagate again */ else if (hasclears) /* does table have white keys? */ linktable(h, &g->allweak); /* may have to clean white keys */ diff --git a/lualib/llex.c b/lualib/llex.c index c4b820e..32cdcf1 100644 --- a/lualib/llex.c +++ b/lualib/llex.c @@ -1,5 +1,5 @@ /* -** $Id: llex.c,v 2.63.1.2 2013/08/30 15:49:41 roberto Exp $ +** $Id: llex.c,v 2.63.1.3 2015/02/09 17:56:34 roberto Exp $ ** Lexical Analyzer ** See Copyright Notice in lua.h */ @@ -152,7 +152,7 @@ static void inclinenumber (LexState *ls) { if (currIsNewline(ls) && ls->current != old) next(ls); /* skip `\n\r' or `\r\n' */ if (++ls->linenumber >= MAX_INT) - luaX_syntaxerror(ls, "chunk has too many lines"); + lexerror(ls, "chunk has too many lines", 0); } diff --git a/lualib/lobject.h b/lualib/lobject.h index 3a630b9..bc0bb69 100644 --- a/lualib/lobject.h +++ b/lualib/lobject.h @@ -1,5 +1,5 @@ /* -** $Id: lobject.h,v 2.71.1.1 2013/04/12 18:48:47 roberto Exp $ +** $Id: lobject.h,v 2.71.1.2 2014/05/07 14:14:58 roberto Exp $ ** Type definitions for Lua objects ** See Copyright Notice in lua.h */ @@ -561,12 +561,12 @@ typedef struct Table { CommonHeader; lu_byte flags; /* 1<
= R(A) + 1 */
+OP_JMP,/* A sBx pc+=sBx; if (A) close all upvalues >= R(A - 1) */
OP_EQ,/* A B C if ((RK(B) == RK(C)) ~= A) then pc++ */
OP_LT,/* A B C if ((RK(B) < RK(C)) ~= A) then pc++ */
OP_LE,/* A B C if ((RK(B) <= RK(C)) ~= A) then pc++ */
diff --git a/lualib/ltablib.c b/lualib/ltablib.c
index 6001224..99764d2 100644
--- a/lualib/ltablib.c
+++ b/lualib/ltablib.c
@@ -1,10 +1,11 @@
/*
-** $Id: ltablib.c,v 1.65.1.1 2013/04/12 18:48:47 roberto Exp $
+** $Id: ltablib.c,v 1.65.1.2 2014/05/07 16:32:55 roberto Exp $
** Library for Table Manipulation
** See Copyright Notice in lua.h
*/
+#include