mirror of
https://github.com/lua/lua
synced 2026-09-29 04:35:58 +03:00
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.)
This commit is contained in:
parent
5276973224
commit
9a2de786de
1 changed files with 2 additions and 0 deletions
2
ltests.c
2
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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue