From e30b54a149782f283190889ee75ccb790be247f6 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 14 Feb 2024 15:31:06 +0100 Subject: [PATCH] Fix segfault when removing mobjs while iterating thinglist --- src/lua_maplib.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lua_maplib.c b/src/lua_maplib.c index ba2ad97a1..5f1618205 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -268,6 +268,8 @@ 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)) + return luaL_error(L, "current entry in thinglist was removed; avoid calling P_RemoveMobj on entries!"); thing = thing->snext; } else