From 8abab58a5ca8b472a4e5f3cd9dc214b48fccd2a3 Mon Sep 17 00:00:00 2001 From: Indev Date: Mon, 12 May 2025 18:02:20 +0300 Subject: [PATCH] Fix game crashing when attempting to print '%s has no field named %s' for few lua userdata objects --- src/lua_consolelib.c | 2 +- src/lua_infolib.c | 4 ++-- src/lua_mobjlib.c | 4 ++-- src/lua_playerlib.c | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/lua_consolelib.c b/src/lua_consolelib.c index 7ddf1a1d7..e1e246d28 100644 --- a/src/lua_consolelib.c +++ b/src/lua_consolelib.c @@ -629,7 +629,7 @@ static int cvar_get(lua_State *L) break; default: if (devparm) - return luaL_error(L, LUA_QL("consvar_t") " has no field named " LUA_QS, field); + return luaL_error(L, LUA_QL("consvar_t") " has no field named " LUA_QS, lua_tostring(L, 2)); else return 0; } diff --git a/src/lua_infolib.c b/src/lua_infolib.c index a82fc947d..3ff2d97ae 100644 --- a/src/lua_infolib.c +++ b/src/lua_infolib.c @@ -385,7 +385,7 @@ static int state_get(lua_State *L) default: { if (devparm) - return luaL_error(L, LUA_QL("state_t") " has no field named " LUA_QS, field); + return luaL_error(L, LUA_QL("state_t") " has no field named " LUA_QS, lua_tostring(L, 2)); return 0; } } @@ -462,7 +462,7 @@ static int state_set(lua_State *L) break; default: - return luaL_error(L, LUA_QL("state_t") " has no field named " LUA_QS, field); + return luaL_error(L, LUA_QL("state_t") " has no field named " LUA_QS, lua_tostring(L, 2)); } return 0; diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 44c43297f..504a1e130 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -877,7 +877,7 @@ static int mapthing_get(lua_State *L) break; default: if (devparm) - return luaL_error(L, LUA_QL("mapthing_t") " has no field named " LUA_QS, field); + return luaL_error(L, LUA_QL("mapthing_t") " has no field named " LUA_QS, lua_tostring(L, 2)); else return 0; } @@ -931,7 +931,7 @@ static int mapthing_set(lua_State *L) mt->mobj = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ)); break; default: - return luaL_error(L, LUA_QL("mapthing_t") " has no field named " LUA_QS, field); + return luaL_error(L, LUA_QL("mapthing_t") " has no field named " LUA_QS, lua_tostring(L, 2)); } return 0; diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index 0b3f9cc1d..9562c5679 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -707,8 +707,8 @@ static int kartstuff_len(lua_State *L) return 1; } -#define NOFIELD luaL_error(L, LUA_QL("ticcmd_t") " has no field named " LUA_QS, field) -#define NOSET luaL_error(L, LUA_QL("ticcmd_t") " field " LUA_QS " should not be set directly.", field) +#define NOFIELD luaL_error(L, LUA_QL("ticcmd_t") " has no field named " LUA_QS, lua_tostring(L, 2)) +#define NOSET luaL_error(L, LUA_QL("ticcmd_t") " field " LUA_QS " should not be set directly.", lua_tostring(L, 2)) enum ticcmd_e {