diff options
author | Richard Mudgett <rmudgett@digium.com> | 2016-04-13 13:50:04 -0500 |
---|---|---|
committer | Richard Mudgett <rmudgett@digium.com> | 2016-04-22 15:45:47 -0500 |
commit | a63656b41975a4f77c8d953b5dc7f966332892f4 (patch) | |
tree | 74d852cbee1a1b01c2205e68f767e8970e6998bf /main/bridge.c | |
parent | 71dfa355403e41850fd7c4cb4228626e5d9476b9 (diff) |
Bridge system: Fix memory leaks and double frees on impart failure.
You cannot reference the passed in features struct after calling
ast_bridge_impart(). Even if the call fails.
Change-Id: I902b88ba0d5d39520e670fb635078a367268ea21
Diffstat (limited to 'main/bridge.c')
-rw-r--r-- | main/bridge.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/main/bridge.c b/main/bridge.c index a56555bc9..64c750b1e 100644 --- a/main/bridge.c +++ b/main/bridge.c @@ -2318,6 +2318,9 @@ int ast_bridge_add_channel(struct ast_bridge *bridge, struct ast_channel *chan, if (chan_bridge) { struct ast_bridge_channel *bridge_channel; + /* The channel is in a bridge so it is not getting any new features. */ + ast_bridge_features_destroy(features); + ast_bridge_lock_both(bridge, chan_bridge); bridge_channel = bridge_find_channel(chan_bridge, chan); @@ -2340,9 +2343,6 @@ int ast_bridge_add_channel(struct ast_bridge *bridge, struct ast_channel *chan, bridge_dissolve_check_stolen(chan_bridge, bridge_channel); ast_bridge_unlock(chan_bridge); ast_bridge_unlock(bridge); - - /* The channel was in a bridge so it is not getting any new features. */ - ast_bridge_features_destroy(features); } else { /* Slightly less easy case. We need to yank channel A from * where he currently is and impart him into our bridge. @@ -2350,6 +2350,7 @@ int ast_bridge_add_channel(struct ast_bridge *bridge, struct ast_channel *chan, yanked_chan = ast_channel_yank(chan); if (!yanked_chan) { ast_log(LOG_WARNING, "Could not gain control of channel %s\n", ast_channel_name(chan)); + ast_bridge_features_destroy(features); return -1; } if (ast_channel_state(yanked_chan) != AST_STATE_UP) { |