From 9c738e3bce5fd975c767bdb90e507f00a52bf355 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Deuc=D0=B5?= <shurd@sasktel.net>
Date: Tue, 8 Apr 2025 14:19:18 -0400
Subject: [PATCH] Grab a copy of the sbbs_t * before destroying ourselves

We need it to return flags_ from the new instance since Win32 debug
builds set sbbs to 0xdddddddd when the object is destroyed.

Should fix issue #904
---
 src/sbbs3/terminal.cpp | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/sbbs3/terminal.cpp b/src/sbbs3/terminal.cpp
index 69f844453d..579dcc7a47 100644
--- a/src/sbbs3/terminal.cpp
+++ b/src/sbbs3/terminal.cpp
@@ -322,13 +322,17 @@ list_node_t *Terminal::find_hotspot(unsigned x, unsigned y)
 
 uint32_t Terminal::flags(bool raw)
 {
+	// Tuck away pointer to sbbs...
+	sbbs_t *sbbs_p = sbbs;
+
 	if (!raw) {
 		uint32_t newflags = get_flags(sbbs);
 		if (newflags != flags_)
 			update_terminal(sbbs);
 	}
-	// We have potentially destructed ourselves now...
-	return sbbs->term->flags_;
+
+	// We have potentially destructed ourselves now... use the new object.
+	return sbbs_p->term->flags_;
 }
 
 void Terminal::insert_indicator() {
-- 
GitLab