[asterisk-commits] res pjsip: Fix leak of persistent endpoint references. (asterisk[14])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Oct 9 15:37:32 CDT 2017


Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/6658 )

Change subject: res_pjsip: Fix leak of persistent endpoint references.
......................................................................

res_pjsip: Fix leak of persistent endpoint references.

Do not manually call sip_endpoint_apply_handler from load_all_endpoints.
This is not necessary and causes memory leaks.

Additionally reinitialize persistent->aors when we reuse a persistent
object with a new endpoint.

ASTERISK-27306

Change-Id: I59bbfc8da8a14d5f4af8c5bb1e71f8592ae823eb
---
M res/res_pjsip/pjsip_configuration.c
1 file changed, 9 insertions(+), 9 deletions(-)

Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  Jenkins2: Approved for Submit



diff --git a/res/res_pjsip/pjsip_configuration.c b/res/res_pjsip/pjsip_configuration.c
index 4374766..a391023 100644
--- a/res/res_pjsip/pjsip_configuration.c
+++ b/res/res_pjsip/pjsip_configuration.c
@@ -1314,6 +1314,14 @@
 		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 @@
 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)

-- 
To view, visit https://gerrit.asterisk.org/6658
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 14
Gerrit-MessageType: merged
Gerrit-Change-Id: I59bbfc8da8a14d5f4af8c5bb1e71f8592ae823eb
Gerrit-Change-Number: 6658
Gerrit-PatchSet: 3
Gerrit-Owner: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-commits/attachments/20171009/ece31a8d/attachment-0001.html>


More information about the asterisk-commits mailing list