[asterisk-commits] kmoore: branch 12 r411804 - /branches/12/res/res_stasis.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Apr 7 09:28:45 CDT 2014


Author: kmoore
Date: Mon Apr  7 09:28:41 2014
New Revision: 411804

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=411804
Log:
Stasis: Fix Stasis() bridge refcount issue

The Stasis() dialplan application monitors what bridge a channel is in
and so necessarily holds on to a bridge pointer. This change ensures
that it also holds on to a reference for that bridge to prevent the
bridge pointer from becoming a dangling pointer.

Modified:
    branches/12/res/res_stasis.c

Modified: branches/12/res/res_stasis.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/res/res_stasis.c?view=diff&rev=411804&r1=411803&r2=411804
==============================================================================
--- branches/12/res/res_stasis.c (original)
+++ branches/12/res/res_stasis.c Mon Apr  7 09:28:41 2014
@@ -777,7 +777,7 @@
 		RAII_VAR(struct ast_frame *, f, NULL, ast_frame_dtor);
 		int r;
 		int command_count;
-		struct ast_bridge *last_bridge;
+		RAII_VAR(struct ast_bridge *, last_bridge, NULL, ao2_cleanup);
 
 		/* Check to see if a bridge absorbed our hangup frame */
 		if (ast_check_hangup_locked(chan)) {
@@ -785,7 +785,7 @@
 		}
 
 		last_bridge = bridge;
-		bridge = stasis_app_get_bridge(control);
+		bridge = ao2_bump(stasis_app_get_bridge(control));
 
 		if (bridge != last_bridge) {
 			app_unsubscribe_bridge(app, last_bridge);
@@ -839,6 +839,7 @@
 
 	app_unsubscribe_bridge(app, stasis_app_get_bridge(control));
 	app_unsubscribe_channel(app, chan);
+	ao2_cleanup(bridge);
 
 	res = send_end_msg(app, chan);
 	if (res != 0) {




More information about the asterisk-commits mailing list