app_followme.c: Grab reference on nativeformats before using it

Fixes a crash due to a lack of proper reference on the nativeformats
object before passing it into ast_request().  Also found potentially
similar use case bugs in app_chanisavail.c, bridge.c, and bridge_basic.c

Fixes: #388
This commit is contained in:
Matthew Fredrickson
2023-10-25 21:14:48 -05:00
parent 582c4645f3
commit b5c31b55c9
4 changed files with 49 additions and 10 deletions

View File

@@ -3288,10 +3288,17 @@ static struct ast_channel *dial_transfer(struct ast_channel *caller, const char
{
struct ast_channel *chan;
int cause;
struct ast_format_cap *caps;
ast_channel_lock(caller);
caps = ao2_bump(ast_channel_nativeformats(caller));
ast_channel_unlock(caller);
/* Now we request a local channel to prepare to call the destination */
chan = ast_request("Local", ast_channel_nativeformats(caller), NULL, caller, destination,
&cause);
chan = ast_request("Local", caps, NULL, caller, destination, &cause);
ao2_cleanup(caps);
if (!chan) {
return NULL;
}