summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2021-03-02 11:35:40 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2021-03-02 11:35:40 -0300
commit9a2de786de5da862404995ddd3408f7ad3d54ee8 (patch)
treed0c6eab13c95ac7a9c6148b9b63dd6df60d3f238
parent5276973224066e591b0f1a79c3b091d395848ac4 (diff)
downloadlua-github-9a2de786de5da862404995ddd3408f7ad3d54ee8.tar.gz
Stack check in warning function for tests
The warning function using for tests need to check the stack before pushing anything. (Warning functions are not expected to access a Lua state, therefore they have no preallocated stack space.)
-rw-r--r--ltests.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/ltests.c b/ltests.c
index da95d027..a50f7830 100644
--- a/ltests.c
+++ b/ltests.c
@@ -121,6 +121,7 @@ static void warnf (void *ud, const char *msg, int tocont) {
strcat(buff, msg); /* add new message to current warning */
if (!tocont) { /* message finished? */
lua_unlock(L);
+ luaL_checkstack(L, 1, "warn stack space");
lua_getglobal(L, "_WARN");
if (!lua_toboolean(L, -1))
lua_pop(L, 1); /* ok, no previous unexpected warning */
@@ -142,6 +143,7 @@ static void warnf (void *ud, const char *msg, int tocont) {
}
case 2: { /* store */
lua_unlock(L);
+ luaL_checkstack(L, 1, "warn stack space");
lua_pushstring(L, buff);
lua_setglobal(L, "_WARN"); /* assign message to global '_WARN' */
lua_lock(L);