Skip to content

Commit

Permalink
Fixed memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
slav-at-attachix committed Nov 6, 2018
1 parent cce7822 commit 51f886c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Sming/SmingCore/Network/Http/Websocket/WebsocketResource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ WebsocketResource::~WebsocketResource()
int WebsocketResource::checkHeaders(HttpServerConnection& connection, HttpRequest& request, HttpResponse& response)
{
WebsocketConnection* socket = new WebsocketConnection(&connection, false);
if(!socket) {
debug_e("Unable to create websocket connection");
return 1;
}

socket->setBinaryHandler(wsBinary);
socket->setMessageHandler(wsMessage);
socket->setConnectionHandler(wsConnect);
Expand All @@ -35,7 +40,7 @@ int WebsocketResource::checkHeaders(HttpServerConnection& connection, HttpReques
}

connection.setTimeOut(USHRT_MAX); //Disable disconnection on connection idle (no rx/tx)

connection.userData = (void *)socket;
connection.setUpgradeCallback(std::bind(&WebsocketConnection::onConnected, socket));

// TODO: Re-Enable Command Executor...
Expand Down

0 comments on commit 51f886c

Please sign in to comment.