From 90165e306d958293bae47dd901e2c672dca95006 Mon Sep 17 00:00:00 2001 From: Matt Jordan Date: Sun, 27 Sep 2015 20:45:50 -0500 Subject: [PATCH] res/res_stasis: Fix accidental subscription to 'all' bridge topic When b99a7052621700a1aa641a1c24308f5873275fc8 was merged, subscribing to a NULL bridge will now cause app_subscribe_bridge to implicitly subscribe to all bridges. Unfortunately, the res_stasis control loop did not check that a bridge changing on a channel's control object was actually also non-NULL. As a result, app_subscribe_bridge will be called with a NULL bridge when a channel leaves a bridge. This causes a new subscription to be made to the bridge. If an application has also subscribed to the bridge, the application will now have two subscriptions: (1) The explicit one created by the app (2) The implicit one accidentally created by the control structure As a result, the 'BridgeDestroyed' event can be sent multiple times. This patch corrects the control loop such that it only subscribes an application to a new bridge if the bridge pointer is non-NULL. ASTERISK-24870 Change-Id: I3510e55f6bc36517c10597ead857b964463c9f4f --- res/res_stasis.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/res/res_stasis.c b/res/res_stasis.c index 25866d9bba..1cab8c389b 100644 --- a/res/res_stasis.c +++ b/res/res_stasis.c @@ -1294,7 +1294,9 @@ int stasis_app_exec(struct ast_channel *chan, const char *app_name, int argc, if (bridge != last_bridge) { app_unsubscribe_bridge(app, last_bridge); - app_subscribe_bridge(app, bridge); + if (bridge) { + app_subscribe_bridge(app, bridge); + } } if (bridge) {