[mod_sofia] Coverity fixes

* [mod_sofia] Coverity CID 1468634 (Resource leak)

* [mod_sofia] Coverity CID 1294467 (Resource leak)

---------

Co-authored-by: Andrey Volk <andywolk@gmail.com>
This commit is contained in:
Jakub Karolczyk 2023-03-30 20:00:40 +01:00 committed by GitHub
parent c540af16ad
commit 9494148b10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 4 deletions

View File

@ -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 */

View File

@ -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);