From 6468e3c14966353de09206d5284354a0eab33c24 Mon Sep 17 00:00:00 2001 From: Patryk Obara Date: Tue, 18 Feb 2020 21:11:24 +0100 Subject: [PATCH] Initialize TCPsocket to nullptr This typedef originates from SDL_net.h, it's an opaque data type used for TCP connections. It's a pointer, therefore prevent copying and assignment in TCPServerSocket to prevent ownership problems. --- src/hardware/serialport/misc_util.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/hardware/serialport/misc_util.h b/src/hardware/serialport/misc_util.h index c420fee3..ce80db18 100644 --- a/src/hardware/serialport/misc_util.h +++ b/src/hardware/serialport/misc_util.h @@ -95,7 +95,7 @@ private: Bit8u *nativetcpstruct = nullptr; #endif - TCPsocket mysock = 0; + TCPsocket mysock = nullptr; SDLNet_SocketSet listensocketset = nullptr; // Items for send buffering @@ -106,10 +106,14 @@ private: struct TCPServerSocket { bool isopen = false; - TCPsocket mysock = 0; + TCPsocket mysock = nullptr; TCPServerSocket(Bit16u port); + TCPServerSocket(const TCPServerSocket&) = delete; // prevent copying + TCPServerSocket& operator=(const TCPServerSocket&) = delete; // prevent assignment + ~TCPServerSocket(); + TCPClientSocket* Accept(); };