Maelstrom: Fixed IPaddress leak in GameInfo::RemoveNode()

From b2235af61929312990acfa6731bca47ef73b7f25 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Tue, 7 Apr 2026 08:28:00 -0700
Subject: [PATCH] Fixed IPaddress leak in GameInfo::RemoveNode()

---
 game/gameinfo.cpp |  2 +-
 game/gameinfo.h   |  6 ++++++
 game/packet.h     | 11 ++++++++++-
 3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/game/gameinfo.cpp b/game/gameinfo.cpp
index 7e4ec7e0..63071797 100644
--- a/game/gameinfo.cpp
+++ b/game/gameinfo.cpp
@@ -360,7 +360,7 @@ GameInfo::RemoveNode(Uint32 nodeID)
 			for (int j = i; j < (GetNumNodes() - 1); ++j) {
 				nodes[j] = nodes[j + 1];
 			}
-			SDL_zero(nodes[GetNumNodes() - 1]);
+			nodes[GetNumNodes() - 1].Reset();
 			--numNodes;
 		} else {
 			++i;
diff --git a/game/gameinfo.h b/game/gameinfo.h
index e63456ba..cccc2427 100644
--- a/game/gameinfo.h
+++ b/game/gameinfo.h
@@ -89,6 +89,12 @@ struct GameInfoNode
 		PING_STATUS status;
 	} ping;
 
+	void Reset() {
+		nodeID = 0;
+		address.Reset();
+		state = 0;
+		SDL_zero(ping);
+	}
 };
 
 // This represents a player in the game, on a particular network node
diff --git a/game/packet.h b/game/packet.h
index 10c2f7b9..144a9f29 100644
--- a/game/packet.h
+++ b/game/packet.h
@@ -30,10 +30,19 @@ struct IPaddress {
 		*this = rhs;
 	}
 	~IPaddress() {
-		NET_UnrefAddress(host);
+		Reset();
+	}
+
+	void Reset() {
+		if (host) {
+			NET_UnrefAddress(host);
+			host = nullptr;
+		}
+		port = 0;
 	}
 
 	IPaddress &operator=(const IPaddress &rhs) {
+		Reset();
 		host = NET_RefAddress(rhs.host);
 		port = rhs.port;
 		return *this;