summaryrefslogtreecommitdiff
path: root/res
diff options
context:
space:
mode:
authorMark Michelson <mmichelson@digium.com>2014-02-13 15:57:21 +0000
committerMark Michelson <mmichelson@digium.com>2014-02-13 15:57:21 +0000
commitdb0d0363af93968ce4c80195572cddda053dfbd1 (patch)
tree90d0b3797b4cd60a6210ac3369f3a098e629214a /res
parentfe1e8e55a1f185bc159d4192f430d7da60e2365a (diff)
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 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@407990 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res')
-rw-r--r--res/res_pjsip/location.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/res/res_pjsip/location.c b/res/res_pjsip/location.c
index dd9037f60..fbc48fe9b 100644
--- a/res/res_pjsip/location.c
+++ b/res/res_pjsip/location.c
@@ -349,7 +349,8 @@ static int format_ami_aor_handler(void *obj, void *arg, int flags)
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 @@ static int format_ami_aor_handler(void *obj, void *arg, int flags)
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));