From 76e8c5cc5793190fe58e968379259209d5819292 Mon Sep 17 00:00:00 2001 From: Andrey Volk Date: Mon, 26 Jul 2021 17:09:53 +0300 Subject: [PATCH] [mod_sofia] Fix possible nua handle leak in sofia_handle_sip_i_refer() --- src/mod/endpoints/mod_sofia/sofia.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 6e6bce2827..25e3278c97 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -9047,6 +9047,7 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t int deny_refer_requests = 0; if (!(b_session = switch_core_session_locate(b_private->uuid))) { + nua_handle_unref_user(bnh); goto done; } b_tech_pvt = (private_object_t *) switch_core_session_get_private(b_session); @@ -9402,7 +9403,6 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t } switch_core_session_rwunlock(b_session); } - nua_handle_unref_user(bnh); } else { /* the other channel is on a different box, we have to go find them */ if (exten && (br_a = switch_channel_get_partner_uuid(channel_a))) { switch_core_session_t *a_session; @@ -9592,6 +9592,8 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t TAG_END()); } } + + if (bnh) nua_handle_unref_user(bnh); goto done; }