From 672e1c323fb3dececf9de0e1437e38c861dc8ac8 Mon Sep 17 00:00:00 2001 From: Alec L Davis Date: Mon, 20 Sep 2010 22:24:51 +0000 Subject: [PATCH] Merged revisions 287661 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.8 ........ r287661 | alecdavis | 2010-09-21 10:21:50 +1200 (Tue, 21 Sep 2010) | 14 lines ast_do_masquerade. Keep channels ao2_container locked while unlink and linking channels. Previously, Masquerade would unlock 'original' and 'clonechan' and allow another masq thread to run. End result would be corrupted memory, and the frequent report 'Bad Magic Number'. (closes issue #17801,#17710) Reported by: notthematrix Patches: Based on bug17801.diff1.txt uploaded by alecdavis (license 585) Tested by: alecdavis Review: https://reviewboard.asterisk.org/r/928 ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@287671 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- main/channel.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/main/channel.c b/main/channel.c index 9954d6613c..7c6a98a903 100644 --- a/main/channel.c +++ b/main/channel.c @@ -5984,9 +5984,6 @@ int ast_do_masquerade(struct ast_channel *original) ao2_unlink(channels, original); ao2_unlink(channels, clonechan); - /* now that both channels are locked and unlinked from the container, it is safe to unlock it */ - ao2_unlock(channels); - ast_debug(4, "Actually Masquerading %s(%d) into the structure of %s(%d)\n", clonechan->name, clonechan->_state, original->name, original->_state); @@ -6269,6 +6266,8 @@ done: ao2_link(channels, original); } + ao2_unlock(channels); + return 0; }