diff options
author | Terry Wilson <twilson@digium.com> | 2012-05-22 16:23:19 +0000 |
---|---|---|
committer | Terry Wilson <twilson@digium.com> | 2012-05-22 16:23:19 +0000 |
commit | 1ffb200c0e8642b7fb5c4f174e0064877f0c3d85 (patch) | |
tree | 603c3d3f6d43349df0dc51b14f0b0fa8494ee2c5 /channels/chan_sip.c | |
parent | c857131945b90dbb44754dfc974b0809635acaaa (diff) |
Resolve crash in subscribing for MWI notifications
ASTOBJ_UNREF sets the variable to NULL after unreffing it, so the variable
should definitely not be used after that. To solve this in the two cases
that affect subscribing for MWI notifications, we instead save the ref
locally, and unref them in the error conditions.
(closes issue ASTERISK-19827)
Reported by: B. R
Review: https://reviewboard.asterisk.org/r/1940/
........
Merged revisions 367266 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........
Merged revisions 367267 from http://svn.asterisk.org/svn/asterisk/branches/10
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@367274 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/chan_sip.c')
-rw-r--r-- | channels/chan_sip.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c index a84adeb75..665daec1a 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -12926,13 +12926,14 @@ static int __sip_subscribe_mwi_do(struct sip_subscription_mwi *mwi) /* If we have no DNS manager let's do a lookup */ if (!mwi->dnsmgr) { char transport[MAXHOSTNAMELEN]; + struct sip_subscription_mwi *saved; snprintf(transport, sizeof(transport), "_%s._%s", get_srv_service(mwi->transport), get_srv_protocol(mwi->transport)); mwi->us.ss.ss_family = get_address_family_filter(&bindaddr); /* Filter address family */ - ASTOBJ_REF(mwi); /* Add a ref for storing the mwi on the dnsmgr for updates */ - ast_dnsmgr_lookup_cb(mwi->hostname, &mwi->us, &mwi->dnsmgr, sip_cfg.srvlookup ? transport : NULL, on_dns_update_mwi, mwi); + saved = ASTOBJ_REF(mwi); + ast_dnsmgr_lookup_cb(mwi->hostname, &mwi->us, &mwi->dnsmgr, sip_cfg.srvlookup ? transport : NULL, on_dns_update_mwi, saved); if (!mwi->dnsmgr) { - ASTOBJ_UNREF(mwi, sip_subscribe_mwi_destroy); /* dnsmgr disabled, remove reference */ + ASTOBJ_UNREF(saved, sip_subscribe_mwi_destroy); /* dnsmgr disabled, remove reference */ } } @@ -30932,10 +30933,12 @@ static void sip_send_all_registers(void) static void sip_send_all_mwi_subscriptions(void) { ASTOBJ_CONTAINER_TRAVERSE(&submwil, 1, do { + struct sip_subscription_mwi *saved; ASTOBJ_WRLOCK(iterator); AST_SCHED_DEL(sched, iterator->resub); - if ((iterator->resub = ast_sched_add(sched, 1, sip_subscribe_mwi_do, ASTOBJ_REF(iterator))) < 0) { - ASTOBJ_UNREF(iterator, sip_subscribe_mwi_destroy); + saved = ASTOBJ_REF(iterator); + if ((iterator->resub = ast_sched_add(sched, 1, sip_subscribe_mwi_do, saved)) < 0) { + ASTOBJ_UNREF(saved, sip_subscribe_mwi_destroy); } ASTOBJ_UNLOCK(iterator); } while (0)); |