[svn-commits] mmichelson: trunk r407990 - in /trunk: ./ res/res_pjsip/location.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Feb 13 09:57:23 CST 2014


Author: mmichelson
Date: Thu Feb 13 09:57:21 2014
New Revision: 407990

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=407990
Log:
Fix crash in AMI PJSIPShowEndpoint action.

If an AOR has no permanent contacts, then the
permanent_contacts container is never allocated.
This makes the code safe in the face of NULLs.

I also changed the variable that counts contacts
from "num" to "total_contacts" since there are now
two variables that are indicate numbers of things.
........

Merged revisions 407988 from http://svn.asterisk.org/svn/asterisk/branches/12

Modified:
    trunk/   (props changed)
    trunk/res/res_pjsip/location.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-12-merged' - no diff available.

Modified: trunk/res/res_pjsip/location.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_pjsip/location.c?view=diff&rev=407990&r1=407989&r2=407990
==============================================================================
--- trunk/res/res_pjsip/location.c (original)
+++ trunk/res/res_pjsip/location.c Thu Feb 13 09:57:21 2014
@@ -349,7 +349,8 @@
 	RAII_VAR(struct ast_str *, buf,
 		 ast_sip_create_ami_event("AorDetail", ami), ast_free);
 
-	int num;
+	int total_contacts;
+	int num_permanent;
 	RAII_VAR(struct ao2_container *, contacts,
 		 ast_sip_location_retrieve_aor_contacts(aor), ao2_cleanup);
 
@@ -363,10 +364,13 @@
 	ast_str_truncate(buf, -1);
 	ast_str_append(&buf, 0, "\r\n");
 
-	num = ao2_container_count(contacts);
-	ast_str_append(&buf, 0, "TotalContacts: %d\r\n", num);
+	total_contacts = ao2_container_count(contacts);
+	num_permanent = aor->permanent_contacts ?
+		ao2_container_count(aor->permanent_contacts) : 0;
+
+	ast_str_append(&buf, 0, "TotalContacts: %d\r\n", total_contacts);
 	ast_str_append(&buf, 0, "ContactsRegistered: %d\r\n",
-		       num - ao2_container_count(aor->permanent_contacts));
+		       total_contacts - num_permanent);
 	ast_str_append(&buf, 0, "EndpointName: %s\r\n",
 		       ast_sorcery_object_get_id(endpoint));
 




More information about the svn-commits mailing list