From 9808d123cdab657313d7975ecff4c6af04054751 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 21 Oct 2024 06:23:05 +0200 Subject: [PATCH] replace those two P_MobjWasRemoved with simple null check insteead since those may actually segfault if null anyways --- src/lua_maplib.c | 2 +- src/p_mobj.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lua_maplib.c b/src/lua_maplib.c index d92cd1f8b..a6bca2ff6 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -281,7 +281,7 @@ static int lib_iterateSectorThinglist(lua_State *L) if (!lua_isnil(L, 1)) { thing = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); - if (P_MobjWasRemoved(thing)) + if (!thing) return luaL_error(L, "current entry in thinglist was removed; avoid calling P_RemoveMobj on entries!"); thing = thing->snext; } diff --git a/src/p_mobj.c b/src/p_mobj.c index a2ce82464..3b06c3737 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3384,7 +3384,7 @@ static void P_PlayerMobjThinker(mobj_t *mobj) I_Assert(mobj->player != NULL); I_Assert(!P_MobjWasRemoved(mobj)); - if (P_MobjWasRemoved(mobj)) + if (!mobj) return; P_MobjCheckWater(mobj); @@ -11126,7 +11126,8 @@ void P_SpawnMapThing(mapthing_t *mthing) mobj = P_SpawnMobj(x, y, z, i); - if (!mobj || P_MobjWasRemoved(mobj)) { + if (!mobj || P_MobjWasRemoved(mobj)) + { CONS_Alert(CONS_ERROR, "Failed to spawn map thing #%d at %d, %d. This will crash vanilla clients!\n", mthing->type, x>>FRACBITS, y>>FRACBITS); return; }