DEADSOFTWARE

net: free peer data before disconnect
authorfgsfds <pvt.fgsfds@gmail.com>
Mon, 21 Mar 2022 16:46:56 +0000 (19:46 +0300)
committerfgsfds <pvt.fgsfds@gmail.com>
Mon, 21 Mar 2022 16:46:56 +0000 (19:46 +0300)
src/game/g_net.pas

index 54b06bf579020e5d0882bbe5b2e7946d710ce1c5..e7cd455d0f586b0763a1b8e5b933eb367e99e069 100644 (file)
@@ -1710,6 +1710,12 @@ begin
     g_Player_Remove(TP.UID);
   end;
 
+  if (TC^.Peer^.data <> nil) then
+  begin
+    FreeMemory(TC^.Peer^.data);
+    TC^.Peer^.data := nil;
+  end;
+
   if (Force) then
     enet_peer_reset(TC^.Peer);
 
@@ -1725,12 +1731,6 @@ begin
   TC^.NetOut[NET_UNRELIABLE].Free();
   TC^.NetOut[NET_RELIABLE].Free();
 
-  if (NetEvent.peer^.data <> nil) then
-  begin
-    FreeMemory(NetEvent.peer^.data);
-    NetEvent.peer^.data := nil;
-  end;
-
   g_Console_Add(_lc[I_NET_MSG] + Format(_lc[I_NET_MSG_HOST_DISC], [ID]));
   Dec(NetClientCount);