summaryrefslogtreecommitdiff
path: root/bridges/bridge_native_rtp.c
diff options
context:
space:
mode:
authorMatthew Jordan <mjordan@digium.com>2013-06-12 02:13:31 +0000
committerMatthew Jordan <mjordan@digium.com>2013-06-12 02:13:31 +0000
commit41e428275101c117607f9a6503f054f13fa8f78b (patch)
treeb6513eb05110098cfe5f5e4f6d9a1bf36a523729 /bridges/bridge_native_rtp.c
parent0e2832d121e97b96093daefe9176f88ba0b9507c (diff)
Fix memory leaks in stasis_channels and bridge_native_rtp
This patch fixes two memory leaks: * A memory leak in packing channels into a multi-channel blob payload when publishing dial messages. The multi-channel blob payload does not steal the references - this approach was chosen because it works well with the RAII_VAR macro. Unfortunately, this does mean that you actually have to use the RAII_VAR macro (or manually deref it yourself) * RTP instances returned as a result of one of the glue operations are ref counted and have to be de-ref'd appropriately. We now do that, as saying that we should do it and then not would be silly. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@391479 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'bridges/bridge_native_rtp.c')
-rw-r--r--bridges/bridge_native_rtp.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/bridges/bridge_native_rtp.c b/bridges/bridge_native_rtp.c
index 3c8e57c93..120a509c1 100644
--- a/bridges/bridge_native_rtp.c
+++ b/bridges/bridge_native_rtp.c
@@ -155,7 +155,10 @@ static int native_rtp_bridge_compatible(struct ast_bridge *bridge)
struct ast_bridge_channel *c1 = AST_LIST_LAST(&bridge->channels);
enum ast_rtp_glue_result native_type;
struct ast_rtp_glue *glue0, *glue1;
- struct ast_rtp_instance *instance0 = NULL, *instance1 = NULL, *vinstance0 = NULL, *vinstance1 = NULL;
+ RAII_VAR(struct ast_rtp_instance *, instance0, NULL, ao2_cleanup);
+ 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_nolock(), ast_format_cap_destroy);
RAII_VAR(struct ast_format_cap *, cap1, ast_format_cap_alloc_nolock(), ast_format_cap_destroy);
int read_ptime0, read_ptime1, write_ptime0, write_ptime1;