From 9994c5149958a52855a19ce79e484c06380b6332 Mon Sep 17 00:00:00 2001 From: Jakub Karolczyk Date: Thu, 6 Apr 2023 01:11:35 +0100 Subject: [PATCH] [mod_xml_rpc] Coverity CID 1294469 (Resource leak) --- src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c b/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c index 43e25b6f9e..8e49462d2c 100644 --- a/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c +++ b/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c @@ -614,7 +614,7 @@ abyss_bool websocket_hook(TSession *r) if (ret != 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "handshake error %d\n", ret); - return FALSE; + goto err; } if (switch_event_bind_removable("websocket", SWITCH_EVENT_CUSTOM, "websocket::stophook", stop_hook_event_handler, wsh, &nodes[node_count++]) != SWITCH_STATUS_SUCCESS) { @@ -696,8 +696,11 @@ abyss_bool websocket_hook(TSession *r) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "wsh->down = %d, node_count = %d\n", wsh->down, node_count); switch_yield(2000); + while (--node_count >= 0) switch_event_unbind(&nodes[node_count]); + err: + ws_destroy(wsh); switch_safe_free(wsh); return FALSE;