Fix redbean's Lua-function Log, so it can be used in the global scope.

Before this fix Log crashed the redbean when Log was used in the global scope.
The demo versions of redbean has a Log in a main function, therefore it didn't crash.
Lua doesn't need a main function and every other redbean Lua-function can also be used in the most outer scope.
This commit is contained in:
w13b3 2021-08-08 00:10:06 +02:00
parent 6bbb44c165
commit cbc9ec92df

View file

@ -4911,7 +4911,7 @@ static int LuaLog(lua_State *L) {
level = luaL_checkinteger(L, 1);
if (LOGGABLE(level)) {
msg = luaL_checkstring(L, 2);
lua_getstack(L, 1, &ar);
lua_getstack(L, 0, &ar);
lua_getinfo(L, "nSl", &ar);
if (!strcmp(ar.name, "main")) {
module = strndup(effectivepath.p, effectivepath.n);