mirror of https://github.com/axmolengine/axmol.git
Fix memory leaks (#18564)
This commit is contained in:
parent
cddcf545db
commit
dfa0360d99
|
@ -570,6 +570,11 @@ WebSocket::~WebSocket()
|
|||
CC_SAFE_DELETE(__wsHelper);
|
||||
}
|
||||
|
||||
for(auto name:_protocolNames){
|
||||
free(name);
|
||||
}
|
||||
free(_lwsProtocols);
|
||||
|
||||
Director::getInstance()->getEventDispatcher()->removeEventListener(_resetDirectorListener);
|
||||
|
||||
*_isDestroyed = true;
|
||||
|
@ -601,6 +606,7 @@ bool WebSocket::init(const Delegate& delegate,
|
|||
_lwsProtocols[i].callback = WebSocketCallbackWrapper::onSocketCallback;
|
||||
size_t nameLen = protocols->at(i).length();
|
||||
char* name = (char*)malloc(nameLen + 1);
|
||||
_protocolNames.push_back(name);
|
||||
name[nameLen] = '\0';
|
||||
strcpy(name, protocols->at(i).c_str());
|
||||
_lwsProtocols[i].name = name;
|
||||
|
|
|
@ -255,6 +255,7 @@ private:
|
|||
|
||||
std::mutex _closeMutex;
|
||||
std::condition_variable _closeCondition;
|
||||
std::vector<char*> _protocolNames;
|
||||
|
||||
enum class CloseState
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue