]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
ast_do_masquerade. Keep channels ao2_container locked while unlink and linking channels.
authorAlec L Davis <sivad.a@paradise.net.nz>
Mon, 20 Sep 2010 22:21:50 +0000 (22:21 +0000)
committerAlec L Davis <sivad.a@paradise.net.nz>
Mon, 20 Sep 2010 22:21:50 +0000 (22:21 +0000)
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

main/channel.c

index 9954d6613c5e8148805cbaa904297f1c013541e3..7c6a98a9034a15982e04eb569fd5ac2c63a8d127 100644 (file)
@@ -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;
 }