[asterisk-commits] channel: Fix reference counting in ast channel suppress. (asterisk[13])
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Jun 15 16:18:27 CDT 2017
Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/5843 )
Change subject: channel: Fix reference counting in ast_channel_suppress.
......................................................................
channel: Fix reference counting in ast_channel_suppress.
The ast_channel_suppress function wrongly decremented the
reference count of the underlying structure used to keep
track of what should be suppressed on a channel if the
function was called multiple times on the same channel.
This change cleans up the reference counting a bit so
this no longer occurs.
ASTERISK-27016
Change-Id: I2eed4077cb4916e6626f9f120b63b963acc5c136
---
M main/channel.c
1 file changed, 4 insertions(+), 3 deletions(-)
Approvals:
George Joseph: Looks good to me, but someone else must approve
Kevin Harwell: Looks good to me, approved
Jenkins2: Approved for Submit
diff --git a/main/channel.c b/main/channel.c
index e1ee516..2addfb5 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -10822,7 +10822,7 @@
int ast_channel_suppress(struct ast_channel *chan, unsigned int direction, enum ast_frame_type frametype)
{
- RAII_VAR(struct suppress_data *, suppress, NULL, ao2_cleanup);
+ struct suppress_data *suppress;
const struct ast_datastore_info *datastore_info = NULL;
struct ast_datastore *datastore = NULL;
struct ast_framehook_interface interface = {
@@ -10858,6 +10858,7 @@
if (framehook_id < 0) {
/* Hook attach failed. Get rid of the evidence. */
ast_log(LOG_WARNING, "Failed to attach framehook while attempting to suppress a stream.\n");
+ ao2_ref(suppress, -1);
return -1;
}
@@ -10869,11 +10870,11 @@
if (!(datastore = ast_datastore_alloc(datastore_info, NULL))) {
ast_log(LOG_WARNING, "Failed to allocate datastore while attempting to suppress a stream.\n");
ast_framehook_detach(chan, framehook_id);
+ ao2_ref(suppress, -1);
return -1;
}
- /* and another ref for the datastore */
- ao2_ref(suppress, +1);
+ /* the ref provided by the allocation is taken by the datastore */
datastore->data = suppress;
ast_channel_datastore_add(chan, datastore);
--
To view, visit https://gerrit.asterisk.org/5843
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: merged
Gerrit-Change-Id: I2eed4077cb4916e6626f9f120b63b963acc5c136
Gerrit-Change-Number: 5843
Gerrit-PatchSet: 1
Gerrit-Owner: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-commits/attachments/20170615/a525a1ab/attachment-0001.html>
More information about the asterisk-commits
mailing list