From 2758cc76e553e89445b5b16b8f7083b44bf98f60 Mon Sep 17 00:00:00 2001 From: Richard Mudgett Date: Mon, 28 Jul 2014 18:58:43 +0000 Subject: datastores: Audit ast_channel_datastore_remove usage. Audit of v1.8 usage of ast_channel_datastore_remove() for datastore memory leaks. * Fixed leaks in app_speech_utils and func_frame_trace. * Fixed app_speech_utils not locking the channel when accessing the channel datastore list. Review: https://reviewboard.asterisk.org/r/3859/ Audit of v11 usage of ast_channel_datastore_remove() for datastore memory leaks. * Fixed leak in func_jitterbuffer. (Was not in v12) Review: https://reviewboard.asterisk.org/r/3860/ Audit of v12 usage of ast_channel_datastore_remove() for datastore memory leaks. * Fixed leaks in abstract_jb. * Fixed leak in ast_channel_unsuppress(). Used by ARI mute control and res_mutestream. * Fixed ref leak in ast_channel_suppress(). Used by ARI mute control and res_mutestream. Review: https://reviewboard.asterisk.org/r/3861/ ........ Merged revisions 419684 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 419685 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 419686 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@419688 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- main/channel.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'main/channel.c') diff --git a/main/channel.c b/main/channel.c index 4ce4e916f..6a252a699 100644 --- a/main/channel.c +++ b/main/channel.c @@ -10415,10 +10415,7 @@ int ast_channel_suppress(struct ast_channel *chan, unsigned int direction, enum if ((datastore = ast_channel_datastore_find(chan, datastore_info, NULL))) { suppress = datastore->data; - ao2_ref(suppress, +1); - suppress->direction |= direction; - return 0; } @@ -10450,13 +10447,12 @@ int ast_channel_suppress(struct ast_channel *chan, unsigned int direction, enum return -1; } + /* and another ref for the datastore */ + ao2_ref(suppress, +1); datastore->data = suppress; ast_channel_datastore_add(chan, datastore); - /* and another ref for the datastore */ - ao2_ref(suppress, +1); - return 0; } @@ -10484,6 +10480,7 @@ int ast_channel_unsuppress(struct ast_channel *chan, unsigned int direction, enu /* Nothing left to suppress. Bye! */ ast_framehook_detach(chan, suppress->framehook_id); ast_channel_datastore_remove(chan, datastore); + ast_datastore_free(datastore); } return 0; -- cgit v1.2.3