Prevent crash during synchronous AMI origination by ref bumping returned channel
authorMatthew Jordan <mjordan@digium.com>
Mon, 1 Jul 2013 21:24:20 +0000 (21:24 +0000)
committerMatthew Jordan <mjordan@digium.com>
Mon, 1 Jul 2013 21:24:20 +0000 (21:24 +0000)
commit3841520a6e4f910c4c44130204b6cc7f4eadf76a
tree6372a032fd3a69200477c97284941b55c9af1f94
parentf820d24db14e657a4c0fc7c6d4c1c73ef4c8f86a
Prevent crash during synchronous AMI origination by ref bumping returned channel

The originate APIs allow callers to provide a pointer to a channel that will
point to the originated channel if the function call succeeds. This is used by AMI
to provide channel information when the originate is performed synchronously.
Unfortunately, if the originate fails in certain ways, the outbound channel is
already disposed of during the dialing itself. This results in the channel being
improperly dereferenced by the internal originate function in pbx.c.

This patch ref bumps the channel to prevent this from occurring. Callers must now
unlock and unref the channel (which is more in line with general channel management
guidelines anyway).

This only affects manager, as it is the only consumer of this API function that
actually passes in a channel pointer.

Review: https://reviewboard.asterisk.org/r/2617/

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@393361 65c4cc65-6c06-0410-ace0-fbb531ad65f3
include/asterisk/pbx.h
main/manager.c
main/pbx.c