From 2647b108406258aac6fcf8bf522cb2be8b68305c Mon Sep 17 00:00:00 2001
From: SMS Alfredo <65426124+SMS-Alfredo@users.noreply.github.com>
Date: Sat, 1 Jul 2023 22:24:11 -0500
Subject: [PATCH] Require valid toucher.player

---
 src/lua_baselib.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/lua_baselib.c b/src/lua_baselib.c
index 8409a8377d..1f8baedc23 100644
--- a/src/lua_baselib.c
+++ b/src/lua_baselib.c
@@ -2204,6 +2204,8 @@ static int lib_pTouchSpecialThing(lua_State *L)
 	INLEVEL
 	if (!special || !toucher)
 		return LUA_ErrInvalid(L, "mobj_t");
+	if (!toucher->player)
+		return luaL_error(L, "P_TouchSpecialThing requires a valid toucher.player.");
 	P_TouchSpecialThing(special, toucher, heightcheck);
 	return 0;
 }
-- 
GitLab