Network: Defer deletion of client and server game socket handler

This fixes various use after free scenarios in error handling paths
This commit is contained in:
Jonathan G Rennison
2023-06-16 20:44:48 +01:00
parent 532d3881cd
commit 495db43b72
5 changed files with 40 additions and 7 deletions

View File

@@ -168,7 +168,8 @@ public:
class NetworkGameSocketHandler : public NetworkTCPSocketHandler {
/* TODO: rewrite into a proper class */
private:
NetworkClientInfo *info; ///< Client info related to this socket
NetworkClientInfo *info; ///< Client info related to this socket
bool is_pending_deletion = false; ///< Whether this socket is pending deletion
protected:
bool ignore_close = false;
@@ -592,6 +593,11 @@ public:
virtual std::string GetDebugInfo() const;
virtual void LogSentPacket(const Packet &pkt) override;
bool IsPendingDeletion() const { return this->is_pending_deletion; }
void DeferDeletion();
static void ProcessDeferredDeletions();
};
#endif /* NETWORK_CORE_TCP_GAME_H */