diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2021-03-02 11:35:40 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2021-03-02 11:35:40 -0300 |
commit | 9a2de786de5da862404995ddd3408f7ad3d54ee8 (patch) | |
tree | d0c6eab13c95ac7a9c6148b9b63dd6df60d3f238 | |
parent | 5276973224066e591b0f1a79c3b091d395848ac4 (diff) | |
download | lua-9a2de786de5da862404995ddd3408f7ad3d54ee8.tar.gz lua-9a2de786de5da862404995ddd3408f7ad3d54ee8.tar.bz2 lua-9a2de786de5da862404995ddd3408f7ad3d54ee8.zip |
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.c | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -121,6 +121,7 @@ static void warnf (void *ud, const char *msg, int tocont) { | |||
121 | strcat(buff, msg); /* add new message to current warning */ | 121 | strcat(buff, msg); /* add new message to current warning */ |
122 | if (!tocont) { /* message finished? */ | 122 | if (!tocont) { /* message finished? */ |
123 | lua_unlock(L); | 123 | lua_unlock(L); |
124 | luaL_checkstack(L, 1, "warn stack space"); | ||
124 | lua_getglobal(L, "_WARN"); | 125 | lua_getglobal(L, "_WARN"); |
125 | if (!lua_toboolean(L, -1)) | 126 | if (!lua_toboolean(L, -1)) |
126 | lua_pop(L, 1); /* ok, no previous unexpected warning */ | 127 | lua_pop(L, 1); /* ok, no previous unexpected warning */ |
@@ -142,6 +143,7 @@ static void warnf (void *ud, const char *msg, int tocont) { | |||
142 | } | 143 | } |
143 | case 2: { /* store */ | 144 | case 2: { /* store */ |
144 | lua_unlock(L); | 145 | lua_unlock(L); |
146 | luaL_checkstack(L, 1, "warn stack space"); | ||
145 | lua_pushstring(L, buff); | 147 | lua_pushstring(L, buff); |
146 | lua_setglobal(L, "_WARN"); /* assign message to global '_WARN' */ | 148 | lua_setglobal(L, "_WARN"); /* assign message to global '_WARN' */ |
147 | lua_lock(L); | 149 | lua_lock(L); |