diff options
author | Richard Mudgett <rmudgett@digium.com> | 2015-04-09 15:54:05 +0000 |
---|---|---|
committer | Richard Mudgett <rmudgett@digium.com> | 2015-04-09 15:54:05 +0000 |
commit | 92c1688edb4652302de73dfba74f8e03d7dca62f (patch) | |
tree | f253404ee806f0e3f76ea6e92eef441bd903a60a | |
parent | 2679d0100af28d47bd320b1e7045bde707517789 (diff) |
bridge_native_rtp.c: Defer allocation and check if it fails in native_rtp_bridge_compatible().
Review: https://reviewboard.asterisk.org/r/4601/
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@434508 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rw-r--r-- | bridges/bridge_native_rtp.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/bridges/bridge_native_rtp.c b/bridges/bridge_native_rtp.c index 980f46716..d5652bc78 100644 --- a/bridges/bridge_native_rtp.c +++ b/bridges/bridge_native_rtp.c @@ -310,8 +310,8 @@ static int native_rtp_bridge_compatible(struct ast_bridge *bridge) RAII_VAR(struct ast_rtp_instance *, instance1, NULL, ao2_cleanup); RAII_VAR(struct ast_rtp_instance *, vinstance0, NULL, ao2_cleanup); RAII_VAR(struct ast_rtp_instance *, vinstance1, NULL, ao2_cleanup); - RAII_VAR(struct ast_format_cap *, cap0, ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT), ao2_cleanup); - RAII_VAR(struct ast_format_cap *, cap1, ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT), ao2_cleanup); + RAII_VAR(struct ast_format_cap *, cap0, NULL, ao2_cleanup); + RAII_VAR(struct ast_format_cap *, cap1, NULL, ao2_cleanup); int read_ptime0, read_ptime1, write_ptime0, write_ptime1; /* We require two channels before even considering native bridging */ @@ -361,6 +361,12 @@ static int native_rtp_bridge_compatible(struct ast_bridge *bridge) return 0; } + cap0 = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT); + cap1 = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT); + if (!cap0 || !cap1) { + return 0; + } + /* Make sure that codecs match */ if (glue0->get_codec) { glue0->get_codec(bc0->chan, cap0); |