diff options
author | Jenkins2 <jenkins2@gerrit.asterisk.org> | 2017-10-09 15:37:31 -0500 |
---|---|---|
committer | Gerrit Code Review <gerrit2@gerrit.digium.api> | 2017-10-09 15:37:31 -0500 |
commit | 3ee963585a567846c941f7ba14554d6a30362b6f (patch) | |
tree | a2f82549ae6b15f8949c3665903e5912f61ea108 | |
parent | 5b4fc0699a52dc60efa9a635a2aa175d05bff634 (diff) | |
parent | cacf938d38c89da68d306796a139bd117ba0e13d (diff) |
Merge "res_pjsip: Fix leak of persistent endpoint references." into 14
-rw-r--r-- | res/res_pjsip/pjsip_configuration.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/res/res_pjsip/pjsip_configuration.c b/res/res_pjsip/pjsip_configuration.c index 437476631..a39102305 100644 --- a/res/res_pjsip/pjsip_configuration.c +++ b/res/res_pjsip/pjsip_configuration.c @@ -1314,6 +1314,14 @@ static struct ast_endpoint *persistent_endpoint_find_or_create(const struct ast_ ast_endpoint_set_state(persistent->endpoint, AST_ENDPOINT_OFFLINE); ao2_link_flags(persistent_endpoints, persistent, OBJ_NOLOCK); + } else if (strcmp(persistent->aors, endpoint->aors)) { + char *new_aors = ast_strdup(endpoint->aors); + + /* make sure we don't NULL persistent->aors if allocation fails. */ + if (new_aors) { + ast_free(persistent->aors); + persistent->aors = new_aors; + } } ao2_ref(persistent->endpoint, +1); @@ -1790,20 +1798,12 @@ static struct ast_cli_entry cli_commands[] = { struct ast_sip_cli_formatter_entry *channel_formatter; struct ast_sip_cli_formatter_entry *endpoint_formatter; -static int on_load_endpoint(void *obj, void *arg, int flags) -{ - return sip_endpoint_apply_handler(sip_sorcery, obj); -} - static void load_all_endpoints(void) { struct ao2_container *endpoints; endpoints = ast_sorcery_retrieve_by_fields(sip_sorcery, "endpoint", AST_RETRIEVE_FLAG_MULTIPLE | AST_RETRIEVE_FLAG_ALL, NULL); - if (endpoints) { - ao2_callback(endpoints, OBJ_NODATA, on_load_endpoint, NULL); - ao2_ref(endpoints, -1); - } + ao2_cleanup(endpoints); } int ast_res_pjsip_initialize_configuration(void) |