]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-12055: [mod_sofia] Fix leaks and release profile properly in general_event_handler...
authorAndrey Volk <andywolk@gmail.com>
Thu, 19 Sep 2019 18:21:30 +0000 (22:21 +0400)
committerAndrey Volk <andywolk@gmail.com>
Mon, 30 Dec 2019 19:58:28 +0000 (23:58 +0400)
src/mod/endpoints/mod_sofia/mod_sofia.c
src/mod/endpoints/mod_sofia/sofia_presence.c

index 72ac5b01b953d6593bcea12dae2cf021ccb9b370..61350bdf7221df7998854538eeb9381515faf3a2 100644 (file)
@@ -5384,6 +5384,9 @@ void general_event_handler(switch_event_t *event)
 
                                        if (zstr(dst->contact)) {
                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid contact uri [%s]\n", switch_str_nil(dst->contact));
+                                               sofia_glue_free_destination(dst);
+                                               switch_safe_free(route_uri);
+                                               sofia_glue_release_profile(profile);
                                                return;
                                        }
 
@@ -5410,10 +5413,10 @@ void general_event_handler(switch_event_t *event)
 
                                        switch_safe_free(route_uri);
                                        sofia_glue_free_destination(dst);
-
-                                       sofia_glue_release_profile(profile);
                                }
 
+                               sofia_glue_release_profile(profile);
+
                                return;
                        } else if (to_uri || from_uri) {
                                if (!es) {
@@ -5465,10 +5468,10 @@ void general_event_handler(switch_event_t *event)
 
                                        switch_safe_free(route_uri);
                                        sofia_glue_free_destination(dst);
-
-                                       sofia_glue_release_profile(profile);
                                }
 
+                               sofia_glue_release_profile(profile);
+
                                return;
                        }
 
@@ -5647,6 +5650,7 @@ void general_event_handler(switch_event_t *event)
 
                                if (!(list = sofia_reg_find_reg_url_multi(profile, user, host))) {
                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't find registered user %s@%s\n", user, host);
+                                       sofia_glue_release_profile(profile);
                                        return;
                                }
 
@@ -5776,10 +5780,12 @@ void general_event_handler(switch_event_t *event)
                                nua_handle_unref(nh);
                        }
 
-                       sofia_glue_release_profile(profile);
-
                  done:
 
+                       if (profile) {
+                               sofia_glue_release_profile(profile);
+                       }
+
                        switch_safe_free(local_dup);
 
                }
index 6e5d15b38159a5ab7a7d712db257fd89f41f48d1..be27121cd1153ef826de3e417ec43135435cedcb 100644 (file)
@@ -1160,6 +1160,7 @@ static switch_event_t *actual_sofia_presence_event_handler(switch_event_t *event
 
                                                if (!mod_sofia_globals.profile_hash) {
                                                        switch_console_free_matches(&matches);
+                                                       sofia_glue_release_profile(profile);
                                                        goto done;
                                                }
 
@@ -1413,6 +1414,7 @@ static switch_event_t *actual_sofia_presence_event_handler(switch_event_t *event
 
 
                                if (zstr(call_id) && (dh.hits && presence_source && (!strcasecmp(presence_source, "register") || switch_stristr("register", status)))) {
+                                       sofia_glue_release_profile(profile);
                                        goto done;
                                }