From fa8bffabfc51ea1d7be86d833190bb7dcf494fca Mon Sep 17 00:00:00 2001 From: toaster Date: Sun, 21 Nov 2021 13:35:08 +0000 Subject: [PATCH] Have replay recording of "hits" use the reference count system, so that it doesn't potentially access free'd memory. (This is not THE replay fix, but it is A replay fix.) --- src/g_demo.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/g_demo.c b/src/g_demo.c index a30d78878..16ca2a859 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -621,7 +621,7 @@ void G_GhostAddHit(INT32 playernum, mobj_t *victim) ghostext[playernum].flags |= EZT_HIT; ghostext[playernum].hits++; ghostext[playernum].hitlist = Z_Realloc(ghostext[playernum].hitlist, ghostext[playernum].hits * sizeof(mobj_t *), PU_LEVEL, NULL); - ghostext[playernum].hitlist[ghostext[playernum].hits-1] = victim; + P_SetTarget(ghostext[playernum].hitlist + (ghostext[playernum].hits-1), victim); } void G_WriteAllGhostTics(void) @@ -793,6 +793,7 @@ void G_WriteGhostTic(mobj_t *ghost, INT32 playernum) WRITEFIXED(demo_p,mo->y); WRITEFIXED(demo_p,mo->z); WRITEANGLE(demo_p,mo->angle); + P_SetTarget(ghostext[playernum].hitlist+i, NULL); } Z_Free(ghostext[playernum].hitlist); ghostext[playernum].hits = 0;