]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[mod_sofia] Fix potential leak of uuid in sofia_event_callback().
authorAndrey Volk <andywolk@gmail.com>
Fri, 17 Jul 2020 16:38:15 +0000 (20:38 +0400)
committerAndrey Volk <andywolk@gmail.com>
Tue, 16 Mar 2021 19:50:02 +0000 (22:50 +0300)
src/mod/endpoints/mod_sofia/sofia.c

index 32ed268b7e39175350452eb28bd18d5e944c77ea..7f7b0c2b75450f1d4bf13dedc6e9231976042fc0 100644 (file)
@@ -2435,11 +2435,16 @@ void sofia_event_callback(nua_event_t event,
                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "detaching session %s\n", sofia_private->uuid);
 
                                                if (!zstr(tech_pvt->call_id)) {
+                                                       char *uuid = strdup(switch_core_session_get_uuid(session));
                                                        tech_pvt->sofia_private = NULL;
                                                        tech_pvt->nh = NULL;
                                                        sofia_set_flag(tech_pvt, TFLAG_BYE);
                                                        switch_mutex_lock(profile->flag_mutex);
-                                                       switch_core_hash_insert_auto_free(profile->chat_hash, tech_pvt->call_id, strdup(switch_core_session_get_uuid(session)));
+
+                                                       if (switch_core_hash_insert_auto_free(profile->chat_hash, tech_pvt->call_id, uuid) != SWITCH_STATUS_SUCCESS) {
+                                                               switch_safe_free(uuid);
+                                                       }
+
                                                        switch_mutex_unlock(profile->flag_mutex);
                                                        nua_handle_destroy(nh);
                                                } else {