[asterisk-commits] twilson: branch 1.8 r367266 - /branches/1.8/channels/chan_sip.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue May 22 11:14:22 CDT 2012
Author: twilson
Date: Tue May 22 11:14:16 2012
New Revision: 367266
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=367266
Log:
Don't use a variable after calling ASTOBJ_UNREF on it
ASTOBJ_UNREF sets the variable to NULL after unreffing it, so the variable
should definitely not be used after that. To solve in these two cases, just
save the ref locally, and unref that on the error condition.
(closes issue ASTERISK-19827)
Reported by: B. R
Review: https://reviewboard.asterisk.org/r/1940/
Modified:
branches/1.8/channels/chan_sip.c
Modified: branches/1.8/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/channels/chan_sip.c?view=diff&rev=367266&r1=367265&r2=367266
==============================================================================
--- branches/1.8/channels/chan_sip.c (original)
+++ branches/1.8/channels/chan_sip.c Tue May 22 11:14:16 2012
@@ -12421,13 +12421,14 @@
/* 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 */
}
}
@@ -29687,10 +29688,12 @@
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));
More information about the asterisk-commits
mailing list