From 7c9b1ee2cbc8fc528d53f37e98d940afd600a3c4 Mon Sep 17 00:00:00 2001
From: Monster Iestyn <iestynjealous@ntlworld.com>
Date: Mon, 30 Dec 2019 11:49:01 +0000
Subject: [PATCH] Fix P_SetTarget crash by setting th->target to NULL first

---
 src/p_polyobj.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/p_polyobj.c b/src/p_polyobj.c
index be56730936..f6f666061c 100644
--- a/src/p_polyobj.c
+++ b/src/p_polyobj.c
@@ -2647,6 +2647,7 @@ INT32 EV_DoPolyObjWaypoint(polywaypointdata_t *pwdata)
 
 	// Set pointnum
 	th->pointnum = target->health;
+	th->target = NULL; // set to NULL first so the below doesn't go wrong
 	// Set the mobj as your target! -- Monster Iestyn 27/12/19
 	P_SetTarget(&th->target, target);
 
-- 
GitLab