]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[mod_sofia] Coverity fixes
authorJakub Karolczyk <jakub.karolczyk@signalwire.com>
Thu, 30 Mar 2023 19:00:40 +0000 (20:00 +0100)
committerGitHub <noreply@github.com>
Thu, 30 Mar 2023 19:00:40 +0000 (22:00 +0300)
* [mod_sofia] Coverity CID 1468634 (Resource leak)

* [mod_sofia] Coverity CID 1294467 (Resource leak)

---------

Co-authored-by: Andrey Volk <andywolk@gmail.com>
src/mod/endpoints/mod_sofia/sofia_glue.c
src/mod/endpoints/mod_sofia/sofia_presence.c

index 35704b44abd0f0564152074bd6d26ae2c8d81041..8c9dfcc57ad5657d30cc02df101a93cabc381b22 100644 (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 */
index 89324ebe824f1df110c46d4f4cc7e0cbaf605503..b8576ae7f563410080d40b38d3de7b82b1193911 100644 (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);