Fix segfault when first mobj in overlaycap is removed

This commit is contained in:
Gustaf Alhäll 2023-04-11 22:13:29 +02:00
parent b98af785f5
commit cb849ca4f0
No known key found for this signature in database
GPG key ID: 6C1F67D690CDEDFD

View file

@ -6900,6 +6900,13 @@ static void P_AddOverlay(mobj_t *thing)
static void P_RemoveOverlay(mobj_t *thing)
{
mobj_t *mo;
if (overlaycap == thing)
{
P_SetTarget(&overlaycap, thing->hnext);
P_SetTarget(&thing->hnext, NULL);
return;
}
for (mo = overlaycap; mo; mo = mo->hnext)
{
if (mo->hnext != thing)