[Asterisk-code-review] Resolve 2 discrete memory leaks, both triggered using DTLS/S... (asterisk[13])

Steve Davies asteriskteam at digium.com
Tue Apr 28 06:00:54 CDT 2015


Steve Davies has uploaded a new change for review.

  https://gerrit.asterisk.org/269

Change subject: Resolve 2 discrete memory leaks, both triggered using DTLS/SRTP code path
......................................................................

Resolve 2 discrete memory leaks, both triggered using DTLS/SRTP code path

Change-Id: I62a8ceb8679709f6c3769136dc6aa9a68202ff9b
---
M main/rtp_engine.c
M res/res_rtp_asterisk.c
2 files changed, 4 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/69/269/1

diff --git a/main/rtp_engine.c b/main/rtp_engine.c
index 444c995..8d6977d 100644
--- a/main/rtp_engine.c
+++ b/main/rtp_engine.c
@@ -1659,6 +1659,8 @@
 
 void ast_rtp_dtls_cfg_copy(const struct ast_rtp_dtls_cfg *src_cfg, struct ast_rtp_dtls_cfg *dst_cfg)
 {
+	ast_rtp_dtls_cfg_free(dst_cfg);         /* Prevent a double-call leaking memory via ast_strdup */
+
 	dst_cfg->enabled = src_cfg->enabled;
 	dst_cfg->verify = src_cfg->verify;
 	dst_cfg->rekey = src_cfg->rekey;
diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c
index 8300ef4..2cc01b9 100644
--- a/res/res_rtp_asterisk.c
+++ b/res/res_rtp_asterisk.c
@@ -1974,6 +1974,8 @@
 		ast_log(LOG_WARNING, "Could not set policies when setting up DTLS-SRTP on '%p'\n", rtp);
 		goto error;
 	}
+	ao2_t_ref(local_policy, -1, "Drop local_policy alloc ref, now has table ref");
+	ao2_t_ref(remote_policy, -1, "Drop remote_policy alloc ref, now has table ref");
 
 	if (rtp->rekey) {
 		ao2_ref(instance, +1);

-- 
To view, visit https://gerrit.asterisk.org/269
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I62a8ceb8679709f6c3769136dc6aa9a68202ff9b
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Steve Davies <steve at one47.co.uk>



More information about the asterisk-code-review mailing list