1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

node-webrtc: fix signaling client memory leak and error handling

Signed-off-by: Philipp Jungkamp <Philipp.Jungkamp@opal-rt.com>
This commit is contained in:
Philipp Jungkamp 2023-06-15 09:12:32 +02:00
parent 59ecd740d4
commit bb61a59103

View file

@ -19,17 +19,22 @@ SignalingClient::SignalingClient(const std::string &srv, const std::string &sess
running(false),
logger(logging.get("webrtc:signal"))
{
int ret;
const char *prot, *a, *p;
memset(&info, 0, sizeof(info));
(void)!asprintf(&uri, "%s/%s", srv.c_str(), sess.c_str());
ret = asprintf(&uri, "%s/%s", srv.c_str(), sess.c_str());
if (ret < 0)
throw RuntimeError { "Could not format signaling server uri" };
int ret = lws_parse_uri(uri, &prot, &a, &info.port, &p);
ret = lws_parse_uri(uri, &prot, &a, &info.port, &p);
if (ret)
throw RuntimeError("Failed to parse WebSocket URI: '{}'", uri);
(void)!asprintf(&path, "/%s", p);
ret = asprintf(&path, "/%s", p);
if (ret < 0)
throw RuntimeError { "Could not format signaling client path" };
info.ssl_connection = !strcmp(prot, "https");
info.address = a;
@ -202,6 +207,8 @@ int SignalingClient::receive(void *in, size_t len)
cbMessage(SignalingMessage { json });
json_decref(json);
return 0;
}