From d7152fea844b55432e4b05933a4bd5213e38e08f Mon Sep 17 00:00:00 2001
From: katsy <katmint@live.com>
Date: Mon, 15 Apr 2024 15:12:18 -0500
Subject: [PATCH] Fix exitgame-ing a demo crashing the game

---
 src/g_demo.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/g_demo.c b/src/g_demo.c
index 0efba5a597..158e05adf0 100644
--- a/src/g_demo.c
+++ b/src/g_demo.c
@@ -549,6 +549,9 @@ void G_ConsGhostTic(void)
 
 	testmo = players[0].mo;
 
+	if (!testmo)
+		return; // No valid mobj exists, probably because of unexpected quit
+
 	// Grab ghost data.
 	ziptic = READUINT8(demo_p);
 	if (ziptic & GZT_XYZ)
-- 
GitLab