diff options
author | Mark Michelson <mmichelson@digium.com> | 2016-01-25 16:51:25 -0600 |
---|---|---|
committer | Mark Michelson <mmichelson@digium.com> | 2016-01-25 16:51:25 -0600 |
commit | 8261bda1bf63d76f0913a5273c9b7ae1729addec (patch) | |
tree | 3856117c237d1840694bfe2db9e56033fc4cffba /res/res_pjsip_pubsub.c | |
parent | a6823bb0c4f33dd19c11cd30f23650a194c2dbb7 (diff) |
res_pjsip_pubsub: Prevent crash from AMI command on freed subscription.
A test recently uncovered that running an ill-timed AMI command to show
inbound subscriptions could cause a crash since Asterisk will try to
operate on a freed subscription.
The fix for this is to remove the subscription tree from the list of
subscriptions at the time that we are sending our final NOTIFY request
out. This way, as the subscription is in the process of dying, it is
inaccessible from AMI.
Change-Id: Ic0239003d8d73e04c47c12dd2a7e23867e5b5b23
Diffstat (limited to 'res/res_pjsip_pubsub.c')
-rw-r--r-- | res/res_pjsip_pubsub.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/res/res_pjsip_pubsub.c b/res/res_pjsip_pubsub.c index cdd1e8029..c91464194 100644 --- a/res/res_pjsip_pubsub.c +++ b/res/res_pjsip_pubsub.c @@ -1202,8 +1202,6 @@ static void subscription_tree_destructor(void *obj) ast_debug(3, "Destroying subscription tree %p\n", sub_tree); - remove_subscription(sub_tree); - ao2_cleanup(sub_tree->endpoint); destroy_subscriptions(sub_tree->root); @@ -3295,6 +3293,7 @@ static void pubsub_on_evsub_state(pjsip_evsub *evsub, pjsip_event *event) } } + remove_subscription(sub_tree); pjsip_evsub_set_mod_data(evsub, pubsub_module.id, NULL); sub_tree->evsub = NULL; ast_sip_dialog_set_serializer(sub_tree->dlg, NULL); |