summaryrefslogtreecommitdiff
path: root/websocketprovider.cpp
diff options
context:
space:
mode:
authorRusty Wagner <rusty.wagner@gmail.com>2023-01-31 21:45:23 -0500
committerAlexander Taylor <alex@vector35.com>2023-02-08 11:53:38 -0500
commitc2247a35e97c96eba9cd4caf09b32b038625cc31 (patch)
treed88022f286bd811667f88cc3926dada7b4ec5d31 /websocketprovider.cpp
parent0b752f36c9d3b6bcb51a05fdcf5b38633d38bdbd (diff)
Clean up possible early deletion issues in API callbacks
Diffstat (limited to 'websocketprovider.cpp')
-rw-r--r--websocketprovider.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/websocketprovider.cpp b/websocketprovider.cpp
index 48782715..52b8e721 100644
--- a/websocketprovider.cpp
+++ b/websocketprovider.cpp
@@ -59,28 +59,28 @@ bool WebsocketClient::ConnectCallback(
headers[headerKeys[i]] = headerValues[i];
}
- WebsocketClient* client = (WebsocketClient*)ctxt;
+ CallbackRef<WebsocketClient> client(ctxt);
return client->Connect(host, headers);
}
bool WebsocketClient::DisconnectCallback(void* ctxt)
{
- WebsocketClient* client = (WebsocketClient*)ctxt;
+ CallbackRef<WebsocketClient> client(ctxt);
return client->Disconnect();
}
void WebsocketClient::ErrorCallback(const char* msg, void* ctxt)
{
- WebsocketClient* client = (WebsocketClient*)ctxt;
+ CallbackRef<WebsocketClient> client(ctxt);
BNNotifyWebsocketClientError(client->m_object, msg);
}
bool WebsocketClient::WriteCallback(const uint8_t* data, uint64_t len, void* ctxt)
{
- WebsocketClient* client = (WebsocketClient*)ctxt;
+ CallbackRef<WebsocketClient> client(ctxt);
return client->Write(vector<uint8_t>(data, data + len));
}