Skip to content

Commit 21f51f0

Browse files
Rubonnekminggo
authored andcommitted
Fixed WebSocket.cpp memory leaks (#17653)
1 parent 1c69779 commit 21f51f0

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

cocos/network/WebSocket.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ void WsThreadHelper::onSubThreadLoop()
362362
if (msg->what == WS_MSG_TO_SUBTHREAD_CREATE_CONNECTION)
363363
{
364364
ws->onClientOpenConnectionRequest();
365+
delete *iter;
365366
iter = __wsHelper->_subThreadWsMessageQueue->erase(iter);
366367
}
367368
else
@@ -509,6 +510,7 @@ void WebSocket::closeAllConnections()
509510

510511
std::lock_guard<std::mutex> lk(__instanceMutex);
511512
__websocketInstances->clear();
513+
delete __websocketInstances;
512514
__websocketInstances = nullptr;
513515
}
514516
}

0 commit comments

Comments
 (0)