From: Alec L Davis Date: Mon, 20 Sep 2010 22:21:50 +0000 (+0000) Subject: ast_do_masquerade. Keep channels ao2_container locked while unlink and linking channels. X-Git-Tag: 1.8.0-rc1~3^2~23 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6f9f45f1dd8bbe54473ca9ced8baa2fa4f22ce21;p=thirdparty%2Fasterisk.git 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/branches/1.8@287661 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- 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; }