aboutsummaryrefslogtreecommitdiff
path: root/ldo.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2024-03-11 14:05:06 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2024-03-11 14:05:06 -0300
commit65b07dd53d7938a60112fc4473f5cad3473e3534 (patch)
tree469c75dba3b194c494b6ad6a30ca44e7e8354ef5 /ldo.c
parent7237eb3f1c480d6bc7fe2832ddd36f2137fb69d9 (diff)
downloadlua-65b07dd53d7938a60112fc4473f5cad3473e3534.tar.gz
lua-65b07dd53d7938a60112fc4473f5cad3473e3534.tar.bz2
lua-65b07dd53d7938a60112fc4473f5cad3473e3534.zip
API asserts for illegal pops of to-be-closed variables
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 05b14ec8..699a9d2a 100644
--- a/ldo.c
+++ b/ldo.c
@@ -767,6 +767,7 @@ static CallInfo *findpcall (lua_State *L) {
767** coroutine error handler and should not kill the coroutine.) 767** coroutine error handler and should not kill the coroutine.)
768*/ 768*/
769static int resume_error (lua_State *L, const char *msg, int narg) { 769static int resume_error (lua_State *L, const char *msg, int narg) {
770 api_checkpop(L, narg);
770 L->top.p -= narg; /* remove args from the stack */ 771 L->top.p -= narg; /* remove args from the stack */
771 setsvalue2s(L, L->top.p, luaS_new(L, msg)); /* push error message */ 772 setsvalue2s(L, L->top.p, luaS_new(L, msg)); /* push error message */
772 api_incr_top(L); 773 api_incr_top(L);
@@ -849,7 +850,7 @@ LUA_API int lua_resume (lua_State *L, lua_State *from, int nargs,
849 return resume_error(L, "C stack overflow", nargs); 850 return resume_error(L, "C stack overflow", nargs);
850 L->nCcalls++; 851 L->nCcalls++;
851 luai_userstateresume(L, nargs); 852 luai_userstateresume(L, nargs);
852 api_checknelems(L, (L->status == LUA_OK) ? nargs + 1 : nargs); 853 api_checkpop(L, (L->status == LUA_OK) ? nargs + 1 : nargs);
853 status = luaD_rawrunprotected(L, resume, &nargs); 854 status = luaD_rawrunprotected(L, resume, &nargs);
854 /* continue running after recoverable errors */ 855 /* continue running after recoverable errors */
855 status = precover(L, status); 856 status = precover(L, status);
@@ -878,7 +879,7 @@ LUA_API int lua_yieldk (lua_State *L, int nresults, lua_KContext ctx,
878 luai_userstateyield(L, nresults); 879 luai_userstateyield(L, nresults);
879 lua_lock(L); 880 lua_lock(L);
880 ci = L->ci; 881 ci = L->ci;
881 api_checknelems(L, nresults); 882 api_checkpop(L, nresults);
882 if (l_unlikely(!yieldable(L))) { 883 if (l_unlikely(!yieldable(L))) {
883 if (L != G(L)->mainthread) 884 if (L != G(L)->mainthread)
884 luaG_runerror(L, "attempt to yield across a C-call boundary"); 885 luaG_runerror(L, "attempt to yield across a C-call boundary");