FS-12055: [mod_sofia] Fix leaks and release profile properly in general_event_handler() and actual_sofia_presence_event_handler()

This commit is contained in:
Andrey Volk 2019-09-19 22:21:30 +04:00
parent b8a18f7d83
commit e2c1e3a7d3
2 changed files with 14 additions and 6 deletions

View 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);
}

View 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;
}