From 42cfcbf7be35372fb10363858488b6f68e74fa22 Mon Sep 17 00:00:00 2001
From: katsy <katmint@live.com>
Date: Sun, 21 Mar 2021 16:09:11 -0500
Subject: [PATCH] fix sigsegv in A_Custom3DRotate

---
 src/p_enemy.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/p_enemy.c b/src/p_enemy.c
index 203e04af12..ceacc1962c 100644
--- a/src/p_enemy.c
+++ b/src/p_enemy.c
@@ -9868,22 +9868,23 @@ void A_Custom3DRotate(mobj_t *actor)
 	if (LUA_CallAction(A_CUSTOM3DROTATE, actor))
 		return;
 
-	if (actor->target->health == 0)
+	if (!actor->target) // Ensure we actually have a target first.
 	{
+		CONS_Printf("Error: A_Custom3DRotate: Object has no target.\n");
 		P_RemoveMobj(actor);
 		return;
 	}
 
-	if (!actor->target) // This should NEVER happen.
+	if (actor->target->health == 0)
 	{
-		if (cv_debug)
-			CONS_Printf("Error: Object has no target\n");
 		P_RemoveMobj(actor);
 		return;
 	}
+
 	if (hspeed==0 && vspeed==0)
 	{
-		CONS_Printf("Error: A_Custom3DRotate: Object has no speed.\n");
+		if (cv_debug)
+			CONS_Printf("Error: A_Custom3DRotate: Object has no speed.\n");
 		return;
 	}
 
-- 
GitLab