[asterisk-commits] res pjsip/location: Fix memory leak in permanent uri handler (asterisk[master])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat May 30 10:19:46 CDT 2015


Joshua Colp has submitted this change and it was merged.

Change subject: res_pjsip/location:  Fix memory leak in permanent_uri_handler
......................................................................


res_pjsip/location:  Fix memory leak in permanent_uri_handler

When permanent_uri_handler was creating the contact status
object for each contact, it wasn't unreffing it at the
end of the loop.

ASTERISK-25141 #close
Reported-by: Corey Farrell

Change-Id: I7bb127994677bb3d459f87952f8425c9b9967b12
---
M res/res_pjsip/location.c
1 file changed, 4 insertions(+), 1 deletion(-)

Approvals:
  Richard Mudgett: Looks good to me, but someone else must approve
  Joshua Colp: Looks good to me, approved; Verified
  Corey Farrell: Looks good to me, but someone else must approve



diff --git a/res/res_pjsip/location.c b/res/res_pjsip/location.c
index 887053b..9e75929 100644
--- a/res/res_pjsip/location.c
+++ b/res/res_pjsip/location.c
@@ -354,6 +354,7 @@
 	contacts = ast_strdupa(var->value);
 	while ((contact_uri = strsep(&contacts, ","))) {
 		struct ast_sip_contact *contact;
+		struct ast_sip_contact_status *status;
 		char contact_id[strlen(aor_id) + strlen(contact_uri) + 2 + 1];
 
 		if (ast_sip_push_task_synchronous(NULL, permanent_contact_validate, contact_uri)) {
@@ -376,10 +377,12 @@
 			return -1;
 		}
 
-		if (!ast_res_pjsip_find_or_create_contact_status(contact)) {
+		status = ast_res_pjsip_find_or_create_contact_status(contact);
+		if (!status) {
 			ao2_ref(contact, -1);
 			return -1;
 		}
+		ao2_ref(status, -1);
 
 		ast_string_field_set(contact, uri, contact_uri);
 		ao2_link(aor->permanent_contacts, contact);

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I7bb127994677bb3d459f87952f8425c9b9967b12
Gerrit-PatchSet: 2
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: George Joseph <george.joseph at fairview5.com>
Gerrit-Reviewer: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>



More information about the asterisk-commits mailing list