From 9494148b109ab55c3311abd6b486031d1f7581ca Mon Sep 17 00:00:00 2001 From: Jakub Karolczyk Date: Thu, 30 Mar 2023 20:00:40 +0100 Subject: [PATCH] [mod_sofia] Coverity fixes * [mod_sofia] Coverity CID 1468634 (Resource leak) * [mod_sofia] Coverity CID 1294467 (Resource leak) --------- Co-authored-by: Andrey Volk --- src/mod/endpoints/mod_sofia/sofia_glue.c | 13 +++++++++---- src/mod/endpoints/mod_sofia/sofia_presence.c | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index 35704b44ab..8c9dfcc57a 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -446,14 +446,16 @@ void sofia_glue_store_session_id(switch_core_session_t *session, sofia_profile_t a_id = switch_strip_whitespace(duped); - if (zstr(a_id)) return; + if (zstr(a_id)) { + goto end; + } p = strchr(a_id, ';'); if (p) *p = '\0'; if (!sofia_glue_is_valid_session_uuid(a_id)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Session-ID: Ignoring \"%s\" parsed as \"%s\"\n", header, a_id); - return; + goto end; } /* RFC7329 compatibility */ @@ -483,7 +485,7 @@ void sofia_glue_store_session_id(switch_core_session_t *session, sofia_profile_t if (!p) { switch_channel_set_flag(channel, CF_RFC7329_COMPAT); switch_channel_set_flag_partner(channel, CF_RFC7329_COMPAT); - return; + goto end; } p++; remote_param = strstr(p, "remote="); @@ -491,7 +493,7 @@ void sofia_glue_store_session_id(switch_core_session_t *session, sofia_profile_t switch_channel_set_flag(channel, CF_RFC7329_COMPAT); switch_channel_set_flag_partner(channel, CF_RFC7329_COMPAT); sofia_glue_check_filter_generic_params(session, profile, p); - return; + goto end; } b_id = remote_param + 7; if (!zstr(b_id) && strlen(b_id) == RFC7989_SESSION_UUID_LEN /*32*/) { @@ -503,6 +505,9 @@ void sofia_glue_store_session_id(switch_core_session_t *session, sofia_profile_t } else { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Session-ID: invalid uuid, ignored.\n"); } + +end: + switch_safe_free(a_id); } /* add "Session-ID:" header */ diff --git a/src/mod/endpoints/mod_sofia/sofia_presence.c b/src/mod/endpoints/mod_sofia/sofia_presence.c index 89324ebe82..b8576ae7f5 100644 --- a/src/mod/endpoints/mod_sofia/sofia_presence.c +++ b/src/mod/endpoints/mod_sofia/sofia_presence.c @@ -399,6 +399,7 @@ switch_status_t sofia_presence_chat_send(switch_event_t *message_event) switch_safe_free(route_uri); switch_safe_free(ffrom); switch_safe_free(dup); + switch_safe_free(extra_headers); if (profile) { switch_thread_rwlock_unlock(profile->rwlock);