Skip to content

Commit

Permalink
[mod_sofia] Coverity fixes
Browse files Browse the repository at this point in the history
* [mod_sofia] Coverity CID 1468634 (Resource leak)

* [mod_sofia] Coverity CID 1294467 (Resource leak)

---------

Co-authored-by: Andrey Volk <[email protected]>
  • Loading branch information
jakubkarolczyk and andywolk authored Mar 30, 2023
1 parent c540af1 commit 9494148
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/mod/endpoints/mod_sofia/sofia_glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -483,15 +485,15 @@ 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=");
if (!remote_param) {
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*/) {
Expand All @@ -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 */
Expand Down
1 change: 1 addition & 0 deletions src/mod/endpoints/mod_sofia/sofia_presence.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 9494148

Please sign in to comment.