From: Andrey Volk Date: Thu, 19 Sep 2019 18:21:30 +0000 (+0400) Subject: FS-12055: [mod_sofia] Fix leaks and release profile properly in general_event_handler... X-Git-Tag: v1.10.2^2~43 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e2c1e3a7d35534590bffb317abb92da541b38515;p=thirdparty%2Ffreeswitch.git FS-12055: [mod_sofia] Fix leaks and release profile properly in general_event_handler() and actual_sofia_presence_event_handler() --- diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 72ac5b01b9..61350bdf72 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -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); } diff --git a/src/mod/endpoints/mod_sofia/sofia_presence.c b/src/mod/endpoints/mod_sofia/sofia_presence.c index 6e5d15b381..be27121cd1 100644 --- a/src/mod/endpoints/mod_sofia/sofia_presence.c +++ b/src/mod/endpoints/mod_sofia/sofia_presence.c @@ -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; }