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:
parent
59ecd740d4
commit
bb61a59103
1 changed files with 10 additions and 3 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue