Skip to content

Commit 1a0bddf

Browse files
authored
[cpp-test mac] 19:Extension->4SocketIOTest->Open SocketIO Endpoint crashfix (#19199)
* [cpp-test mac] 19:Extension->4SocketIOTest->Open SocketIO Endpoint crash fix * remove redundant condit
1 parent 356d0f2 commit 1a0bddf

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

cocos/network/SocketIO.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -1039,7 +1039,7 @@ SIOClient::SIOClient(const std::string& path, SIOClientImpl* impl, SocketIO::SIO
10391039
, _socket(impl)
10401040
, _delegate(&delegate)
10411041
{
1042-
1042+
CC_SAFE_RETAIN(_socket);
10431043
}
10441044

10451045
SIOClient::~SIOClient()
@@ -1048,6 +1048,7 @@ SIOClient::~SIOClient()
10481048
{
10491049
_socket->disconnectFromEndpoint(_path);
10501050
}
1051+
CC_SAFE_RELEASE(_socket);
10511052
}
10521053

10531054
void SIOClient::onOpen()
@@ -1129,7 +1130,7 @@ void SIOClient::socketClosed()
11291130

11301131
bool SIOClient::isConnected() const
11311132
{
1132-
return _socket && _socket->_connected && _connected;
1133+
return _connected && _socket && _socket->_connected ;
11331134
}
11341135

11351136
void SIOClient::setConnected(bool connected)

0 commit comments

Comments
 (0)